Unverified Commit c733864a authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Step 1 of 3: Add opt-in for debugCheckHasMaterialLocalizations assertion on TextField (#56090)

parent ae462038
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// TODO(Piinks): Remove ignoring deprecated member use analysis
// when TextField.canAssertMaterialLocalizations parameter is removed.
// ignore_for_file: deprecated_member_use_from_same_package
import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle; import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -348,6 +352,7 @@ class TextField extends StatefulWidget { ...@@ -348,6 +352,7 @@ class TextField extends StatefulWidget {
this.scrollController, this.scrollController,
this.scrollPhysics, this.scrollPhysics,
this.autofillHints, this.autofillHints,
bool canAssertMaterialLocalizations,
}) : assert(textAlign != null), }) : assert(textAlign != null),
assert(readOnly != null), assert(readOnly != null),
assert(autofocus != null), assert(autofocus != null),
...@@ -393,6 +398,7 @@ class TextField extends StatefulWidget { ...@@ -393,6 +398,7 @@ class TextField extends StatefulWidget {
selectAll: true, selectAll: true,
paste: true, paste: true,
)), )),
canAssertMaterialLocalizations = canAssertMaterialLocalizations ?? false,
super(key: key); super(key: key);
/// Controls the text being edited. /// Controls the text being edited.
...@@ -724,6 +730,16 @@ class TextField extends StatefulWidget { ...@@ -724,6 +730,16 @@ class TextField extends StatefulWidget {
/// {@macro flutter.widgets.editableText.autofillHints} /// {@macro flutter.widgets.editableText.autofillHints}
final Iterable<String> autofillHints; final Iterable<String> autofillHints;
/// Indicates whether [debugCheckHasMaterialLocalizations] can be called
/// during build.
@Deprecated(
'Set canAssertMaterialLocalizations to `true`. This parameter will be '
'removed and was introduced to migrate TextField to assert '
'debugCheckHasMaterialLocalizations by default. '
'This feature was deprecated after v1.18.0.'
)
final bool canAssertMaterialLocalizations;
@override @override
_TextFieldState createState() => _TextFieldState(); _TextFieldState createState() => _TextFieldState();
...@@ -964,8 +980,8 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe ...@@ -964,8 +980,8 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
// TODO(jonahwilliams): uncomment out this check once we have migrated tests. if (widget.canAssertMaterialLocalizations)
// assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasMaterialLocalizations(context));
assert(debugCheckHasDirectionality(context)); assert(debugCheckHasDirectionality(context));
assert( assert(
!(widget.style != null && widget.style.inherit == false && !(widget.style != null && widget.style.inherit == false &&
......
...@@ -55,17 +55,13 @@ void main() { ...@@ -55,17 +55,13 @@ void main() {
testWidgets('PhysicalModel - creates a physical model layer when it needs compositing', (WidgetTester tester) async { testWidgets('PhysicalModel - creates a physical model layer when it needs compositing', (WidgetTester tester) async {
debugDisableShadows = false; debugDisableShadows = false;
await tester.pumpWidget( await tester.pumpWidget(
MediaQuery( MaterialApp(
data: const MediaQueryData(devicePixelRatio: 1.0), home: PhysicalModel(
child: Directionality( shape: BoxShape.rectangle,
textDirection: TextDirection.ltr, color: Colors.grey,
child: PhysicalModel( shadowColor: Colors.red,
shape: BoxShape.rectangle, elevation: 1.0,
color: Colors.grey, child: Material(child: TextField(controller: TextEditingController())),
shadowColor: Colors.red,
elevation: 1.0,
child: Material(child: TextField(controller: TextEditingController())),
),
), ),
), ),
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment