Unverified Commit 3c21775c authored by Darren Austin's avatar Darren Austin Committed by GitHub

Migrate Material framework tests to null safety (#67556)

Migrate Material framework tests to null safety.
parent 9e206a0c
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -56,7 +54,7 @@ void main() { ...@@ -56,7 +54,7 @@ void main() {
overflowDirection: VerticalDirection.up, overflowDirection: VerticalDirection.up,
); );
final ButtonBarThemeData lerp = ButtonBarThemeData.lerp(barThemePrimary, barThemeAccent, 0.5); final ButtonBarThemeData lerp = ButtonBarThemeData.lerp(barThemePrimary, barThemeAccent, 0.5)!;
expect(lerp.alignment, equals(MainAxisAlignment.center)); expect(lerp.alignment, equals(MainAxisAlignment.center));
expect(lerp.mainAxisSize, equals(MainAxisSize.max)); expect(lerp.mainAxisSize, equals(MainAxisSize.max));
expect(lerp.buttonTextTheme, equals(ButtonTextTheme.accent)); expect(lerp.buttonTextTheme, equals(ButtonTextTheme.accent));
...@@ -114,7 +112,7 @@ void main() { ...@@ -114,7 +112,7 @@ void main() {
testWidgets('ButtonBarTheme.of falls back to ThemeData.buttonBarTheme', (WidgetTester tester) async { testWidgets('ButtonBarTheme.of falls back to ThemeData.buttonBarTheme', (WidgetTester tester) async {
const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0); const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0);
BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(buttonBarTheme: buttonBarTheme), theme: ThemeData(buttonBarTheme: buttonBarTheme),
...@@ -133,7 +131,7 @@ void main() { ...@@ -133,7 +131,7 @@ void main() {
testWidgets('ButtonBarTheme overrides ThemeData.buttonBarTheme', (WidgetTester tester) async { testWidgets('ButtonBarTheme overrides ThemeData.buttonBarTheme', (WidgetTester tester) async {
const ButtonBarThemeData defaultBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0); const ButtonBarThemeData defaultBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0);
const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 84.0); const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 84.0);
BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(buttonBarTheme: defaultBarTheme), theme: ThemeData(buttonBarTheme: defaultBarTheme),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -39,13 +37,13 @@ void main() { ...@@ -39,13 +37,13 @@ void main() {
}); });
testWidgets('ButtonTheme defaults', (WidgetTester tester) async { testWidgets('ButtonTheme defaults', (WidgetTester tester) async {
ButtonTextTheme textTheme; late ButtonTextTheme textTheme;
ButtonBarLayoutBehavior layoutBehavior; late ButtonBarLayoutBehavior layoutBehavior;
BoxConstraints constraints; late BoxConstraints constraints;
EdgeInsets padding; late EdgeInsets padding;
ShapeBorder shape; late ShapeBorder shape;
bool alignedDropdown; late bool alignedDropdown;
ColorScheme colorScheme; late ColorScheme colorScheme;
await tester.pumpWidget( await tester.pumpWidget(
ButtonTheme( ButtonTheme(
...@@ -57,7 +55,7 @@ void main() { ...@@ -57,7 +55,7 @@ void main() {
padding = theme.padding as EdgeInsets; padding = theme.padding as EdgeInsets;
shape = theme.shape; shape = theme.shape;
layoutBehavior = theme.layoutBehavior; layoutBehavior = theme.layoutBehavior;
colorScheme = theme.colorScheme; colorScheme = theme.colorScheme!;
alignedDropdown = theme.alignedDropdown; alignedDropdown = theme.alignedDropdown;
return Container( return Container(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
...@@ -121,10 +119,10 @@ void main() { ...@@ -121,10 +119,10 @@ void main() {
testWidgets('Theme buttonTheme defaults', (WidgetTester tester) async { testWidgets('Theme buttonTheme defaults', (WidgetTester tester) async {
final ThemeData lightTheme = ThemeData.light(); final ThemeData lightTheme = ThemeData.light();
ButtonTextTheme textTheme; late ButtonTextTheme textTheme;
BoxConstraints constraints; late BoxConstraints constraints;
EdgeInsets padding; late EdgeInsets padding;
ShapeBorder shape; late ShapeBorder shape;
const Color disabledColor = Color(0xFF00FF00); const Color disabledColor = Color(0xFF00FF00);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -133,7 +131,7 @@ void main() { ...@@ -133,7 +131,7 @@ void main() {
disabledColor: disabledColor, // disabled RaisedButton fill color disabledColor: disabledColor, // disabled RaisedButton fill color
buttonTheme: const ButtonThemeData(disabledColor: disabledColor), buttonTheme: const ButtonThemeData(disabledColor: disabledColor),
textTheme: lightTheme.textTheme.copyWith( textTheme: lightTheme.textTheme.copyWith(
button: lightTheme.textTheme.button.copyWith( button: lightTheme.textTheme.button!.copyWith(
// The button's height will match because there's no // The button's height will match because there's no
// vertical padding by default // vertical padding by default
fontSize: 48.0, fontSize: 48.0,
...@@ -175,10 +173,10 @@ void main() { ...@@ -175,10 +173,10 @@ void main() {
}); });
testWidgets('Theme buttonTheme ButtonTheme overrides', (WidgetTester tester) async { testWidgets('Theme buttonTheme ButtonTheme overrides', (WidgetTester tester) async {
ButtonTextTheme textTheme; late ButtonTextTheme textTheme;
BoxConstraints constraints; late BoxConstraints constraints;
EdgeInsets padding; late EdgeInsets padding;
ShapeBorder shape; late ShapeBorder shape;
await tester.pumpWidget( await tester.pumpWidget(
Theme( Theme(
...@@ -228,12 +226,12 @@ void main() { ...@@ -228,12 +226,12 @@ void main() {
testWidgets('ButtonTheme alignedDropdown', (WidgetTester tester) async { testWidgets('ButtonTheme alignedDropdown', (WidgetTester tester) async {
final Key dropdownKey = UniqueKey(); final Key dropdownKey = UniqueKey();
Widget buildFrame({ bool alignedDropdown, TextDirection textDirection }) { Widget buildFrame({ required bool alignedDropdown, required TextDirection textDirection }) {
return MaterialApp( return MaterialApp(
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child!,
); );
}, },
home: ButtonTheme( home: ButtonTheme(
...@@ -248,7 +246,7 @@ void main() { ...@@ -248,7 +246,7 @@ void main() {
width: 200.0, width: 200.0,
child: DropdownButton<String>( child: DropdownButton<String>(
key: dropdownKey, key: dropdownKey,
onChanged: (String value) { }, onChanged: (String? value) { },
value: 'foo', value: 'foo',
items: const <DropdownMenuItem<String>>[ items: const <DropdownMenuItem<String>>[
DropdownMenuItem<String>( DropdownMenuItem<String>(
...@@ -374,7 +372,7 @@ void main() { ...@@ -374,7 +372,7 @@ void main() {
); );
Color textColor() { Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('FlatButton')).text.style.color; return tester.renderObject<RenderParagraph>(find.text('FlatButton')).text.style!.color!;
} }
// Default, not disabled. // Default, not disabled.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -178,7 +176,7 @@ void main() { ...@@ -178,7 +176,7 @@ void main() {
testWidgets('Card clipBehavior property defers to theme when null', (WidgetTester tester) async { testWidgets('Card clipBehavior property defers to theme when null', (WidgetTester tester) async {
await tester.pumpWidget(Builder(builder: (BuildContext context) { await tester.pumpWidget(Builder(builder: (BuildContext context) {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context)!;
return Theme( return Theme(
data: themeData.copyWith( data: themeData.copyWith(
cardTheme: themeData.cardTheme.copyWith( cardTheme: themeData.cardTheme.copyWith(
...@@ -223,4 +221,4 @@ void main() { ...@@ -223,4 +221,4 @@ void main() {
expect(_getCardMaterial(tester).shadowColor, _getCard(tester).shadowColor); expect(_getCardMaterial(tester).shadowColor, _getCard(tester).shadowColor);
expect(_getCardMaterial(tester).shadowColor, Colors.red); expect(_getCardMaterial(tester).shadowColor, Colors.red);
}); });
} }
\ No newline at end of file
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
// 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.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
Widget wrap({ Widget child }) { Widget wrap({ required Widget child }) {
return MediaQuery( return MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: Directionality( child: Directionality(
...@@ -25,7 +23,7 @@ void main() { ...@@ -25,7 +23,7 @@ void main() {
await tester.pumpWidget(wrap( await tester.pumpWidget(wrap(
child: CheckboxListTile( child: CheckboxListTile(
value: true, value: true,
onChanged: (bool value) { log.add(value); }, onChanged: (bool? value) { log.add(value); },
title: const Text('Hello'), title: const Text('Hello'),
), ),
)); ));
...@@ -36,12 +34,12 @@ void main() { ...@@ -36,12 +34,12 @@ void main() {
}); });
testWidgets('CheckboxListTile checkColor test', (WidgetTester tester) async { testWidgets('CheckboxListTile checkColor test', (WidgetTester tester) async {
Widget buildFrame(Color color) { Widget buildFrame(Color? color) {
return wrap( return wrap(
child: CheckboxListTile( child: CheckboxListTile(
value: true, value: true,
checkColor: color, checkColor: color,
onChanged: (bool value) {}, onChanged: (bool? value) {},
), ),
); );
} }
...@@ -52,22 +50,22 @@ void main() { ...@@ -52,22 +50,22 @@ void main() {
await tester.pumpWidget(buildFrame(null)); await tester.pumpWidget(buildFrame(null));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(getCheckboxListTileRenderer(), paints..path(color: const Color(0xFFFFFFFF))); // paints's color is 0xFFFFFFFF (default color) expect(getCheckboxListTileRenderer(), paints..path(color: const Color(0xFFFFFFFF)));
await tester.pumpWidget(buildFrame(const Color(0xFF000000))); await tester.pumpWidget(buildFrame(const Color(0xFF000000)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(getCheckboxListTileRenderer(), paints..path(color: const Color(0xFF000000))); // paints's color is 0xFF000000 (params) expect(getCheckboxListTileRenderer(), paints..path(color: const Color(0xFF000000)));
}); });
testWidgets('CheckboxListTile activeColor test', (WidgetTester tester) async { testWidgets('CheckboxListTile activeColor test', (WidgetTester tester) async {
Widget buildFrame(Color themeColor, Color activeColor) { Widget buildFrame(Color? themeColor, Color? activeColor) {
return wrap( return wrap(
child: Theme( child: Theme(
data: ThemeData(toggleableActiveColor: themeColor), data: ThemeData(toggleableActiveColor: themeColor),
child: CheckboxListTile( child: CheckboxListTile(
value: true, value: true,
activeColor: activeColor, activeColor: activeColor,
onChanged: (bool value) {}, onChanged: (bool? value) {},
), ),
), ),
); );
...@@ -78,11 +76,11 @@ void main() { ...@@ -78,11 +76,11 @@ void main() {
await tester.pumpWidget(buildFrame(const Color(0xFF000000), null)); await tester.pumpWidget(buildFrame(const Color(0xFF000000), null));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(getCheckboxListTileRenderer(), paints..rrect(color: const Color(0xFF000000))); // paints's color is 0xFF000000 (theme) expect(getCheckboxListTileRenderer(), paints..rrect(color: const Color(0xFF000000)));
await tester.pumpWidget(buildFrame(const Color(0xFF000000), const Color(0xFFFFFFFF))); await tester.pumpWidget(buildFrame(const Color(0xFF000000), const Color(0xFFFFFFFF)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(getCheckboxListTileRenderer(), paints..rrect(color: const Color(0xFFFFFFFF))); // paints's color is 0xFFFFFFFF (params) expect(getCheckboxListTileRenderer(), paints..rrect(color: const Color(0xFFFFFFFF)));
}); });
testWidgets('CheckboxListTile can autofocus unless disabled.', (WidgetTester tester) async { testWidgets('CheckboxListTile can autofocus unless disabled.', (WidgetTester tester) async {
...@@ -100,7 +98,7 @@ void main() { ...@@ -100,7 +98,7 @@ void main() {
); );
await tester.pump(); await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isTrue); expect(Focus.of(childKey.currentContext!, nullOk: true)!.hasPrimaryFocus, isTrue);
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
...@@ -114,7 +112,7 @@ void main() { ...@@ -114,7 +112,7 @@ void main() {
); );
await tester.pump(); await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isFalse); expect(Focus.of(childKey.currentContext!, nullOk: true)!.hasPrimaryFocus, isFalse);
}); });
testWidgets('CheckboxListTile contentPadding test', (WidgetTester tester) async { testWidgets('CheckboxListTile contentPadding test', (WidgetTester tester) async {
...@@ -148,7 +146,7 @@ void main() { ...@@ -148,7 +146,7 @@ void main() {
}); });
testWidgets('CheckboxListTile tristate test', (WidgetTester tester) async { testWidgets('CheckboxListTile tristate test', (WidgetTester tester) async {
bool _value = false; bool? _value = false;
bool _tristate = false; bool _tristate = false;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -160,7 +158,7 @@ void main() { ...@@ -160,7 +158,7 @@ void main() {
title: const Text('Title'), title: const Text('Title'),
tristate: _tristate, tristate: _tristate,
value: _value, value: _value,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
_value = value; _value = value;
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -30,7 +28,7 @@ void main() { ...@@ -30,7 +28,7 @@ void main() {
child: Center( child: Center(
child: Checkbox( child: Checkbox(
value: true, value: true,
onChanged: (bool newValue) { }, onChanged: (bool? newValue) { },
), ),
), ),
), ),
...@@ -49,7 +47,7 @@ void main() { ...@@ -49,7 +47,7 @@ void main() {
child: Center( child: Center(
child: Checkbox( child: Checkbox(
value: true, value: true,
onChanged: (bool newValue) { }, onChanged: (bool? newValue) { },
), ),
), ),
), ),
...@@ -66,7 +64,7 @@ void main() { ...@@ -66,7 +64,7 @@ void main() {
await tester.pumpWidget(Material( await tester.pumpWidget(Material(
child: Checkbox( child: Checkbox(
value: false, value: false,
onChanged: (bool b) { }, onChanged: (bool? b) { },
), ),
)); ));
...@@ -81,7 +79,7 @@ void main() { ...@@ -81,7 +79,7 @@ void main() {
await tester.pumpWidget(Material( await tester.pumpWidget(Material(
child: Checkbox( child: Checkbox(
value: true, value: true,
onChanged: (bool b) { }, onChanged: (bool? b) { },
), ),
)); ));
...@@ -139,7 +137,7 @@ void main() { ...@@ -139,7 +137,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Checkbox( child: Checkbox(
value: false, value: false,
onChanged: (bool b) { }, onChanged: (bool? b) { },
), ),
), ),
)); ));
...@@ -157,7 +155,7 @@ void main() { ...@@ -157,7 +155,7 @@ void main() {
}); });
testWidgets('CheckBox tristate: true', (WidgetTester tester) async { testWidgets('CheckBox tristate: true', (WidgetTester tester) async {
bool checkBoxValue; bool? checkBoxValue;
await tester.pumpWidget( await tester.pumpWidget(
Material( Material(
...@@ -166,7 +164,7 @@ void main() { ...@@ -166,7 +164,7 @@ void main() {
return Checkbox( return Checkbox(
tristate: true, tristate: true,
value: checkBoxValue, value: checkBoxValue,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
checkBoxValue = value; checkBoxValue = value;
}); });
...@@ -207,7 +205,7 @@ void main() { ...@@ -207,7 +205,7 @@ void main() {
child: Checkbox( child: Checkbox(
tristate: true, tristate: true,
value: null, value: null,
onChanged: (bool newValue) { }, onChanged: (bool? newValue) { },
), ),
), ),
); );
...@@ -227,7 +225,7 @@ void main() { ...@@ -227,7 +225,7 @@ void main() {
child: Checkbox( child: Checkbox(
tristate: true, tristate: true,
value: true, value: true,
onChanged: (bool newValue) { }, onChanged: (bool? newValue) { },
), ),
), ),
); );
...@@ -248,7 +246,7 @@ void main() { ...@@ -248,7 +246,7 @@ void main() {
child: Checkbox( child: Checkbox(
tristate: true, tristate: true,
value: false, value: false,
onChanged: (bool newValue) { }, onChanged: (bool? newValue) { },
), ),
), ),
); );
...@@ -268,7 +266,7 @@ void main() { ...@@ -268,7 +266,7 @@ void main() {
testWidgets('has semantic events', (WidgetTester tester) async { testWidgets('has semantic events', (WidgetTester tester) async {
dynamic semanticEvent; dynamic semanticEvent;
bool checkboxValue = false; bool? checkboxValue = false;
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvent = message; semanticEvent = message;
}); });
...@@ -280,7 +278,7 @@ void main() { ...@@ -280,7 +278,7 @@ void main() {
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return Checkbox( return Checkbox(
value: checkboxValue, value: checkboxValue,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
checkboxValue = value; checkboxValue = value;
}); });
...@@ -297,24 +295,24 @@ void main() { ...@@ -297,24 +295,24 @@ void main() {
expect(checkboxValue, true); expect(checkboxValue, true);
expect(semanticEvent, <String, dynamic>{ expect(semanticEvent, <String, dynamic>{
'type': 'tap', 'type': 'tap',
'nodeId': object.debugSemantics.id, 'nodeId': object.debugSemantics!.id,
'data': <String, dynamic>{}, 'data': <String, dynamic>{},
}); });
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.tap), true); expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
SystemChannels.accessibility.setMockMessageHandler(null); SystemChannels.accessibility.setMockMessageHandler(null);
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('CheckBox tristate rendering, programmatic transitions', (WidgetTester tester) async { testWidgets('CheckBox tristate rendering, programmatic transitions', (WidgetTester tester) async {
Widget buildFrame(bool checkboxValue) { Widget buildFrame(bool? checkboxValue) {
return Material( return Material(
child: StatefulBuilder( child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return Checkbox( return Checkbox(
tristate: true, tristate: true,
value: checkboxValue, value: checkboxValue,
onChanged: (bool value) { }, onChanged: (bool? value) { },
); );
}, },
), ),
...@@ -357,7 +355,7 @@ void main() { ...@@ -357,7 +355,7 @@ void main() {
}); });
testWidgets('CheckBox color rendering', (WidgetTester tester) async { testWidgets('CheckBox color rendering', (WidgetTester tester) async {
Widget buildFrame({Color activeColor, Color checkColor, ThemeData themeData}) { Widget buildFrame({Color? activeColor, Color? checkColor, ThemeData? themeData}) {
return Material( return Material(
child: Theme( child: Theme(
data: themeData ?? ThemeData(), data: themeData ?? ThemeData(),
...@@ -367,7 +365,7 @@ void main() { ...@@ -367,7 +365,7 @@ void main() {
value: true, value: true,
activeColor: activeColor, activeColor: activeColor,
checkColor: checkColor, checkColor: checkColor,
onChanged: (bool value) { }, onChanged: (bool? value) { },
); );
}, },
), ),
...@@ -401,7 +399,7 @@ void main() { ...@@ -401,7 +399,7 @@ void main() {
testWidgets('Checkbox is focusable and has correct focus color', (WidgetTester tester) async { testWidgets('Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool value = true; bool? value = true;
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
...@@ -409,7 +407,7 @@ void main() { ...@@ -409,7 +407,7 @@ void main() {
child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) { child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return Checkbox( return Checkbox(
value: value, value: value,
onChanged: enabled ? (bool newValue) { onChanged: enabled ? (bool? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
...@@ -474,7 +472,7 @@ void main() { ...@@ -474,7 +472,7 @@ void main() {
testWidgets('Checkbox can be hovered and has correct hover color', (WidgetTester tester) async { testWidgets('Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool value = true; bool? value = true;
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
...@@ -482,7 +480,7 @@ void main() { ...@@ -482,7 +480,7 @@ void main() {
child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) { child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return Checkbox( return Checkbox(
value: value, value: value,
onChanged: enabled ? (bool newValue) { onChanged: enabled ? (bool? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
...@@ -539,7 +537,7 @@ void main() { ...@@ -539,7 +537,7 @@ void main() {
testWidgets('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async { testWidgets('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool value = true; bool? value = true;
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
...@@ -547,7 +545,7 @@ void main() { ...@@ -547,7 +545,7 @@ void main() {
child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) { child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return Checkbox( return Checkbox(
value: value, value: value,
onChanged: enabled ? (bool newValue) { onChanged: enabled ? (bool? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
...@@ -587,7 +585,7 @@ void main() { ...@@ -587,7 +585,7 @@ void main() {
child: Checkbox( child: Checkbox(
visualDensity: visualDensity, visualDensity: visualDensity,
key: key, key: key,
onChanged: (bool value) {}, onChanged: (bool? value) {},
value: true, value: true,
), ),
), ),
...@@ -616,7 +614,7 @@ void main() { ...@@ -616,7 +614,7 @@ void main() {
testWidgets('Checkbox stops hover animation when removed from the tree.', (WidgetTester tester) async { testWidgets('Checkbox stops hover animation when removed from the tree.', (WidgetTester tester) async {
const Key checkboxKey = Key('checkbox'); const Key checkboxKey = Key('checkbox');
bool checkboxVal = true; bool? checkboxVal = true;
await tester.pumpWidget( await tester.pumpWidget(
Theme( Theme(
...@@ -629,7 +627,7 @@ void main() { ...@@ -629,7 +627,7 @@ void main() {
builder: (_, StateSetter setState) => Checkbox( builder: (_, StateSetter setState) => Checkbox(
key: checkboxKey, key: checkboxKey,
value: checkboxVal, value: checkboxVal,
onChanged: (bool newValue) => setState(() {checkboxVal = newValue;}), onChanged: (bool? newValue) => setState(() {checkboxVal = newValue;}),
), ),
), ),
), ),
...@@ -696,7 +694,7 @@ void main() { ...@@ -696,7 +694,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor // Test default cursor
await tester.pumpWidget( await tester.pumpWidget(
...@@ -718,7 +716,7 @@ void main() { ...@@ -718,7 +716,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
// Test default cursor when disabled // Test default cursor when disabled
await tester.pumpWidget( await tester.pumpWidget(
...@@ -740,7 +738,7 @@ void main() { ...@@ -740,7 +738,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
// Test cursor when tristate // Test cursor when tristate
await tester.pumpWidget( await tester.pumpWidget(
...@@ -764,7 +762,7 @@ void main() { ...@@ -764,7 +762,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.grab); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.grab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:ui' show window; import 'dart:ui' show window;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -73,7 +71,7 @@ double getEnableProgress(WidgetTester tester) => getRenderChip(tester)?.enableAn ...@@ -73,7 +71,7 @@ double getEnableProgress(WidgetTester tester) => getRenderChip(tester)?.enableAn
/// Adds the basic requirements for a Chip. /// Adds the basic requirements for a Chip.
Widget _wrapForChip({ Widget _wrapForChip({
Widget child, required Widget child,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
double textScaleFactor = 1.0, double textScaleFactor = 1.0,
Brightness brightness = Brightness.light, Brightness brightness = Brightness.light,
...@@ -96,8 +94,8 @@ Widget _wrapForChip({ ...@@ -96,8 +94,8 @@ Widget _wrapForChip({
/// cause the chip or label to exceed its constrained height. /// cause the chip or label to exceed its constrained height.
Future<void> _testConstrainedLabel( Future<void> _testConstrainedLabel(
WidgetTester tester, { WidgetTester tester, {
CircleAvatar avatar, CircleAvatar? avatar,
VoidCallback onDeleted, VoidCallback? onDeleted,
}) async { }) async {
const double labelWidth = 100.0; const double labelWidth = 100.0;
const double labelHeight = 50.0; const double labelHeight = 50.0;
...@@ -134,7 +132,7 @@ Future<void> _testConstrainedLabel( ...@@ -134,7 +132,7 @@ Future<void> _testConstrainedLabel(
expect(chipSize.height, chipParentHeight); expect(chipSize.height, chipParentHeight);
} }
Widget _selectedInputChip({ Color checkmarkColor }) { Widget _selectedInputChip({ Color? checkmarkColor }) {
return InputChip( return InputChip(
label: const Text('InputChip'), label: const Text('InputChip'),
selected: true, selected: true,
...@@ -143,7 +141,7 @@ Widget _selectedInputChip({ Color checkmarkColor }) { ...@@ -143,7 +141,7 @@ Widget _selectedInputChip({ Color checkmarkColor }) {
); );
} }
Widget _selectedFilterChip({ Color checkmarkColor }) { Widget _selectedFilterChip({ Color? checkmarkColor }) {
return FilterChip( return FilterChip(
label: const Text('InputChip'), label: const Text('InputChip'),
selected: true, selected: true,
...@@ -155,8 +153,8 @@ Widget _selectedFilterChip({ Color checkmarkColor }) { ...@@ -155,8 +153,8 @@ Widget _selectedFilterChip({ Color checkmarkColor }) {
Future<void> _pumpCheckmarkChip( Future<void> _pumpCheckmarkChip(
WidgetTester tester, { WidgetTester tester, {
@required Widget chip, required Widget chip,
Color themeColor, Color? themeColor,
Brightness brightness = Brightness.light, Brightness brightness = Brightness.light,
}) async { }) async {
await tester.pumpWidget( await tester.pumpWidget(
...@@ -191,9 +189,9 @@ void _expectCheckmarkColor(Finder finder, Color color) { ...@@ -191,9 +189,9 @@ void _expectCheckmarkColor(Finder finder, Color color) {
} }
Widget _chipWithOptionalDeleteButton({ Widget _chipWithOptionalDeleteButton({
UniqueKey deleteButtonKey, UniqueKey? deleteButtonKey,
UniqueKey labelKey, UniqueKey? labelKey,
bool deletable, required bool deletable,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
}){ }){
return _wrapForChip( return _wrapForChip(
...@@ -394,7 +392,7 @@ void main() { ...@@ -394,7 +392,7 @@ void main() {
'the chip when it exceeds the available space', 'the chip when it exceeds the available space',
(WidgetTester tester) async { (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/11523 // Regression test for https://github.com/flutter/flutter/issues/11523
Widget chipBuilder (String text, {Widget avatar, VoidCallback onDeleted}) { Widget chipBuilder (String text, {Widget? avatar, VoidCallback? onDeleted}) {
return MaterialApp( return MaterialApp(
home: Scaffold( home: Scaffold(
body: Container( body: Container(
...@@ -770,7 +768,7 @@ void main() { ...@@ -770,7 +768,7 @@ void main() {
testWidgets('Avatar drawer works as expected on RawChip', (WidgetTester tester) async { testWidgets('Avatar drawer works as expected on RawChip', (WidgetTester tester) async {
final GlobalKey labelKey = GlobalKey(); final GlobalKey labelKey = GlobalKey();
Future<void> pushChip({ Widget avatar }) async { Future<void> pushChip({ Widget? avatar }) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
...@@ -1195,7 +1193,7 @@ void main() { ...@@ -1195,7 +1193,7 @@ void main() {
testWidgets('Selection with avatar works as expected on RawChip', (WidgetTester tester) async { testWidgets('Selection with avatar works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<void> pushChip({ Widget avatar, bool selectable = false }) async { Future<void> pushChip({ Widget? avatar, bool selectable = false }) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
...@@ -1241,7 +1239,7 @@ void main() { ...@@ -1241,7 +1239,7 @@ void main() {
// Simulate a tap on the label to select the chip. // Simulate a tap on the label to select the chip.
await tester.tap(find.byKey(labelKey)); await tester.tap(find.byKey(labelKey));
expect(selected, equals(true)); expect(selected, equals(true));
expect(SchedulerBinding.instance.transientCallbackCount, equals(2)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(2));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect(getSelectProgress(tester), moreOrLessEquals(0.002, epsilon: 0.01)); expect(getSelectProgress(tester), moreOrLessEquals(0.002, epsilon: 0.01));
...@@ -1259,7 +1257,7 @@ void main() { ...@@ -1259,7 +1257,7 @@ void main() {
// Simulate another tap on the label to deselect the chip. // Simulate another tap on the label to deselect the chip.
await tester.tap(find.byKey(labelKey)); await tester.tap(find.byKey(labelKey));
expect(selected, equals(false)); expect(selected, equals(false));
expect(SchedulerBinding.instance.transientCallbackCount, equals(2)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(2));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
expect(getSelectProgress(tester), moreOrLessEquals(0.875, epsilon: 0.01)); expect(getSelectProgress(tester), moreOrLessEquals(0.875, epsilon: 0.01));
...@@ -1317,7 +1315,7 @@ void main() { ...@@ -1317,7 +1315,7 @@ void main() {
// Simulate a tap on the label to select the chip. // Simulate a tap on the label to select the chip.
await tester.tap(find.byKey(labelKey)); await tester.tap(find.byKey(labelKey));
expect(selected, equals(true)); expect(selected, equals(true));
expect(SchedulerBinding.instance.transientCallbackCount, equals(2)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(2));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect(getSelectProgress(tester), moreOrLessEquals(0.002, epsilon: 0.01)); expect(getSelectProgress(tester), moreOrLessEquals(0.002, epsilon: 0.01));
...@@ -1335,7 +1333,7 @@ void main() { ...@@ -1335,7 +1333,7 @@ void main() {
// Simulate another tap on the label to deselect the chip. // Simulate another tap on the label to deselect the chip.
await tester.tap(find.byKey(labelKey)); await tester.tap(find.byKey(labelKey));
expect(selected, equals(false)); expect(selected, equals(false));
expect(SchedulerBinding.instance.transientCallbackCount, equals(2)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(2));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
expect(getSelectProgress(tester), moreOrLessEquals(0.875, epsilon: 0.01)); expect(getSelectProgress(tester), moreOrLessEquals(0.875, epsilon: 0.01));
...@@ -1354,7 +1352,7 @@ void main() { ...@@ -1354,7 +1352,7 @@ void main() {
testWidgets('Activation works as expected on RawChip', (WidgetTester tester) async { testWidgets('Activation works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<void> pushChip({ Widget avatar, bool selectable = false }) async { Future<void> pushChip({ Widget? avatar, bool selectable = false }) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
...@@ -1392,7 +1390,7 @@ void main() { ...@@ -1392,7 +1390,7 @@ void main() {
await tester.tap(find.byKey(labelKey)); await tester.tap(find.byKey(labelKey));
expect(selected, equals(true)); expect(selected, equals(true));
expect(SchedulerBinding.instance.transientCallbackCount, equals(2)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(2));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect(getSelectProgress(tester), moreOrLessEquals(0.002, epsilon: 0.01)); expect(getSelectProgress(tester), moreOrLessEquals(0.002, epsilon: 0.01));
...@@ -1484,9 +1482,9 @@ void main() { ...@@ -1484,9 +1482,9 @@ void main() {
final ChipThemeData defaultChipTheme = themeData.chipTheme; final ChipThemeData defaultChipTheme = themeData.chipTheme;
bool value = false; bool value = false;
Widget buildApp({ Widget buildApp({
ChipThemeData chipTheme, ChipThemeData? chipTheme,
Widget avatar, Widget? avatar,
Widget deleteIcon, Widget? deleteIcon,
bool isSelectable = true, bool isSelectable = true,
bool isPressable = false, bool isPressable = false,
bool isDeletable = true, bool isDeletable = true,
...@@ -1506,7 +1504,7 @@ void main() { ...@@ -1506,7 +1504,7 @@ void main() {
avatar: avatar, avatar: avatar,
deleteIcon: deleteIcon, deleteIcon: deleteIcon,
isEnabled: isSelectable || isPressable, isEnabled: isSelectable || isPressable,
shape: chipTheme.shape, shape: chipTheme?.shape,
selected: isSelectable && value, selected: isSelectable && value,
label: Text('$value'), label: Text('$value'),
onSelected: isSelectable onSelected: isSelectable
...@@ -2296,20 +2294,6 @@ void main() { ...@@ -2296,20 +2294,6 @@ void main() {
expect(find.byType(InkWell), findsOneWidget); expect(find.byType(InkWell), findsOneWidget);
}); });
testWidgets('RawChip.selected can not be null', (WidgetTester tester) async {
expect(() async {
MaterialApp(
home: Material(
child: RawChip(
onPressed: () { },
selected: null,
label: const Text('Chip'),
),
),
);
}, throwsAssertionError);
});
testWidgets('Chip uses stateful color for text color in different states', (WidgetTester tester) async { testWidgets('Chip uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
...@@ -2355,7 +2339,7 @@ void main() { ...@@ -2355,7 +2339,7 @@ void main() {
); );
} }
Color textColor() { Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('Chip')).text.style.color; return tester.renderObject<RenderParagraph>(find.text('Chip')).text.style!.color!;
} }
// Default, not disabled. // Default, not disabled.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:ui' show window; import 'dart:ui' show window;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -171,7 +169,7 @@ void main() { ...@@ -171,7 +169,7 @@ void main() {
testWidgets('ChipThemeData generates correct opacities for defaults', (WidgetTester tester) async { testWidgets('ChipThemeData generates correct opacities for defaults', (WidgetTester tester) async {
const Color customColor1 = Color(0xcafefeed); const Color customColor1 = Color(0xcafefeed);
const Color customColor2 = Color(0xdeadbeef); const Color customColor2 = Color(0xdeadbeef);
final TextStyle customStyle = ThemeData.fallback().textTheme.bodyText1.copyWith(color: customColor2); final TextStyle customStyle = ThemeData.fallback().textTheme.bodyText1!.copyWith(color: customColor2);
final ChipThemeData lightTheme = ChipThemeData.fromDefaults( final ChipThemeData lightTheme = ChipThemeData.fromDefaults(
secondaryColor: customColor1, secondaryColor: customColor1,
...@@ -232,7 +230,7 @@ void main() { ...@@ -232,7 +230,7 @@ void main() {
final ChipThemeData chipThemeBlack = ChipThemeData.fromDefaults( final ChipThemeData chipThemeBlack = ChipThemeData.fromDefaults(
secondaryColor: Colors.black, secondaryColor: Colors.black,
brightness: Brightness.dark, brightness: Brightness.dark,
labelStyle: ThemeData.fallback().textTheme.bodyText1.copyWith(color: Colors.black), labelStyle: ThemeData.fallback().textTheme.bodyText1!.copyWith(color: Colors.black),
).copyWith( ).copyWith(
elevation: 1.0, elevation: 1.0,
labelPadding: const EdgeInsets.symmetric(horizontal: 8.0), labelPadding: const EdgeInsets.symmetric(horizontal: 8.0),
...@@ -244,7 +242,7 @@ void main() { ...@@ -244,7 +242,7 @@ void main() {
final ChipThemeData chipThemeWhite = ChipThemeData.fromDefaults( final ChipThemeData chipThemeWhite = ChipThemeData.fromDefaults(
secondaryColor: Colors.white, secondaryColor: Colors.white,
brightness: Brightness.light, brightness: Brightness.light,
labelStyle: ThemeData.fallback().textTheme.bodyText1.copyWith(color: Colors.white), labelStyle: ThemeData.fallback().textTheme.bodyText1!.copyWith(color: Colors.white),
).copyWith( ).copyWith(
padding: const EdgeInsets.all(2.0), padding: const EdgeInsets.all(2.0),
labelPadding: const EdgeInsets.only(top: 8.0, bottom: 8.0), labelPadding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
...@@ -255,7 +253,7 @@ void main() { ...@@ -255,7 +253,7 @@ void main() {
checkmarkColor: Colors.white, checkmarkColor: Colors.white,
); );
final ChipThemeData lerp = ChipThemeData.lerp(chipThemeBlack, chipThemeWhite, 0.5); final ChipThemeData lerp = ChipThemeData.lerp(chipThemeBlack, chipThemeWhite, 0.5)!;
const Color middleGrey = Color(0xff7f7f7f); const Color middleGrey = Color(0xff7f7f7f);
expect(lerp.backgroundColor, equals(middleGrey.withAlpha(0x1f))); expect(lerp.backgroundColor, equals(middleGrey.withAlpha(0x1f)));
expect(lerp.deleteIconColor, equals(middleGrey.withAlpha(0xde))); expect(lerp.deleteIconColor, equals(middleGrey.withAlpha(0xde)));
...@@ -276,7 +274,7 @@ void main() { ...@@ -276,7 +274,7 @@ void main() {
expect(ChipThemeData.lerp(null, null, 0.25), isNull); expect(ChipThemeData.lerp(null, null, 0.25), isNull);
final ChipThemeData lerpANull25 = ChipThemeData.lerp(null, chipThemeWhite, 0.25); final ChipThemeData lerpANull25 = ChipThemeData.lerp(null, chipThemeWhite, 0.25)!;
expect(lerpANull25.backgroundColor, equals(Colors.black.withAlpha(0x08))); expect(lerpANull25.backgroundColor, equals(Colors.black.withAlpha(0x08)));
expect(lerpANull25.deleteIconColor, equals(Colors.black.withAlpha(0x38))); expect(lerpANull25.deleteIconColor, equals(Colors.black.withAlpha(0x38)));
expect(lerpANull25.disabledColor, equals(Colors.black.withAlpha(0x03))); expect(lerpANull25.disabledColor, equals(Colors.black.withAlpha(0x03)));
...@@ -294,7 +292,7 @@ void main() { ...@@ -294,7 +292,7 @@ void main() {
expect(lerpANull25.pressElevation, 2.5); expect(lerpANull25.pressElevation, 2.5);
expect(lerpANull25.checkmarkColor, equals(Colors.white.withAlpha(0x40))); expect(lerpANull25.checkmarkColor, equals(Colors.white.withAlpha(0x40)));
final ChipThemeData lerpANull75 = ChipThemeData.lerp(null, chipThemeWhite, 0.75); final ChipThemeData lerpANull75 = ChipThemeData.lerp(null, chipThemeWhite, 0.75)!;
expect(lerpANull75.backgroundColor, equals(Colors.black.withAlpha(0x17))); expect(lerpANull75.backgroundColor, equals(Colors.black.withAlpha(0x17)));
expect(lerpANull75.deleteIconColor, equals(Colors.black.withAlpha(0xa7))); expect(lerpANull75.deleteIconColor, equals(Colors.black.withAlpha(0xa7)));
expect(lerpANull75.disabledColor, equals(Colors.black.withAlpha(0x09))); expect(lerpANull75.disabledColor, equals(Colors.black.withAlpha(0x09)));
...@@ -312,7 +310,7 @@ void main() { ...@@ -312,7 +310,7 @@ void main() {
expect(lerpANull75.pressElevation, 7.5); expect(lerpANull75.pressElevation, 7.5);
expect(lerpANull75.checkmarkColor, equals(Colors.white.withAlpha(0xbf))); expect(lerpANull75.checkmarkColor, equals(Colors.white.withAlpha(0xbf)));
final ChipThemeData lerpBNull25 = ChipThemeData.lerp(chipThemeBlack, null, 0.25); final ChipThemeData lerpBNull25 = ChipThemeData.lerp(chipThemeBlack, null, 0.25)!;
expect(lerpBNull25.backgroundColor, equals(Colors.white.withAlpha(0x17))); expect(lerpBNull25.backgroundColor, equals(Colors.white.withAlpha(0x17)));
expect(lerpBNull25.deleteIconColor, equals(Colors.white.withAlpha(0xa7))); expect(lerpBNull25.deleteIconColor, equals(Colors.white.withAlpha(0xa7)));
expect(lerpBNull25.disabledColor, equals(Colors.white.withAlpha(0x09))); expect(lerpBNull25.disabledColor, equals(Colors.white.withAlpha(0x09)));
...@@ -330,7 +328,7 @@ void main() { ...@@ -330,7 +328,7 @@ void main() {
expect(lerpBNull25.pressElevation, 3.0); expect(lerpBNull25.pressElevation, 3.0);
expect(lerpBNull25.checkmarkColor, equals(Colors.black.withAlpha(0xbf))); expect(lerpBNull25.checkmarkColor, equals(Colors.black.withAlpha(0xbf)));
final ChipThemeData lerpBNull75 = ChipThemeData.lerp(chipThemeBlack, null, 0.75); final ChipThemeData lerpBNull75 = ChipThemeData.lerp(chipThemeBlack, null, 0.75)!;
expect(lerpBNull75.backgroundColor, equals(Colors.white.withAlpha(0x08))); expect(lerpBNull75.backgroundColor, equals(Colors.white.withAlpha(0x08)));
expect(lerpBNull75.deleteIconColor, equals(Colors.white.withAlpha(0x38))); expect(lerpBNull75.deleteIconColor, equals(Colors.white.withAlpha(0x38)));
expect(lerpBNull75.disabledColor, equals(Colors.white.withAlpha(0x03))); expect(lerpBNull75.disabledColor, equals(Colors.white.withAlpha(0x03)));
...@@ -402,7 +400,7 @@ void main() { ...@@ -402,7 +400,7 @@ void main() {
); );
} }
Color textColor() { Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('Chip')).text.style.color; return tester.renderObject<RenderParagraph>(find.text('Chip')).text.style!.color!;
} }
// Default, not disabled. // Default, not disabled.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -32,7 +30,7 @@ void main() { ...@@ -32,7 +30,7 @@ void main() {
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
}); });
testWidgets('CircleAvatar with light background color', (WidgetTester tester) async { testWidgets('CircleAvatar with light background color', (WidgetTester tester) async {
...@@ -54,7 +52,7 @@ void main() { ...@@ -54,7 +52,7 @@ void main() {
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorDark)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorDark));
}); });
testWidgets('CircleAvatar with image background', (WidgetTester tester) async { testWidgets('CircleAvatar with image background', (WidgetTester tester) async {
...@@ -71,7 +69,7 @@ void main() { ...@@ -71,7 +69,7 @@ void main() {
expect(box.size, equals(const Size(100.0, 100.0))); expect(box.size, equals(const Size(100.0, 100.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.image.fit, equals(BoxFit.cover)); expect(decoration.image!.fit, equals(BoxFit.cover));
}); });
testWidgets('CircleAvatar with foreground color', (WidgetTester tester) async { testWidgets('CircleAvatar with foreground color', (WidgetTester tester) async {
...@@ -94,7 +92,7 @@ void main() { ...@@ -94,7 +92,7 @@ void main() {
expect(decoration.color, equals(fallback.primaryColorDark)); expect(decoration.color, equals(fallback.primaryColorDark));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(foregroundColor)); expect(paragraph.text.style!.color, equals(foregroundColor));
}); });
testWidgets('CircleAvatar with light theme', (WidgetTester tester) async { testWidgets('CircleAvatar with light theme', (WidgetTester tester) async {
...@@ -119,7 +117,7 @@ void main() { ...@@ -119,7 +117,7 @@ void main() {
expect(decoration.color, equals(theme.primaryColorLight)); expect(decoration.color, equals(theme.primaryColorLight));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(theme.primaryTextTheme.headline6.color)); expect(paragraph.text.style!.color, equals(theme.primaryTextTheme.headline6!.color));
}); });
testWidgets('CircleAvatar with dark theme', (WidgetTester tester) async { testWidgets('CircleAvatar with dark theme', (WidgetTester tester) async {
...@@ -144,7 +142,7 @@ void main() { ...@@ -144,7 +142,7 @@ void main() {
expect(decoration.color, equals(theme.primaryColorDark)); expect(decoration.color, equals(theme.primaryColorDark));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(theme.primaryTextTheme.headline6.color)); expect(paragraph.text.style!.color, equals(theme.primaryTextTheme.headline6!.color));
}); });
testWidgets('CircleAvatar text does not expand with textScaleFactor', (WidgetTester tester) async { testWidgets('CircleAvatar text does not expand with textScaleFactor', (WidgetTester tester) async {
...@@ -171,7 +169,7 @@ void main() { ...@@ -171,7 +169,7 @@ void main() {
child: CircleAvatar( child: CircleAvatar(
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
final MediaQueryData data = MediaQuery.of(context); final MediaQueryData data = MediaQuery.of(context)!;
// These should not change. // These should not change.
expect(data.size, equals(const Size(111.0, 111.0))); expect(data.size, equals(const Size(111.0, 111.0)));
...@@ -211,7 +209,7 @@ void main() { ...@@ -211,7 +209,7 @@ void main() {
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
}); });
testWidgets('CircleAvatar respects maxRadius', (WidgetTester tester) async { testWidgets('CircleAvatar respects maxRadius', (WidgetTester tester) async {
...@@ -233,7 +231,7 @@ void main() { ...@@ -233,7 +231,7 @@ void main() {
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
}); });
testWidgets('CircleAvatar respects setting both minRadius and maxRadius', (WidgetTester tester) async { testWidgets('CircleAvatar respects setting both minRadius and maxRadius', (WidgetTester tester) async {
...@@ -256,11 +254,11 @@ void main() { ...@@ -256,11 +254,11 @@ void main() {
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
final RenderParagraph paragraph = tester.renderObject(find.text('Z')); final RenderParagraph paragraph = tester.renderObject(find.text('Z'));
expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
}); });
} }
Widget wrap({ Widget child }) { Widget wrap({ required Widget child }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: MediaQuery( child: MediaQuery(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -31,16 +29,16 @@ void main() { ...@@ -31,16 +29,16 @@ void main() {
expect(color.value, 500); expect(color.value, 500);
expect(color[50].value, 0x00000050); expect(color[50]!.value, 0x00000050);
expect(color[100].value, 0x00000100); expect(color[100]!.value, 0x00000100);
expect(color[200].value, 0x00000200); expect(color[200]!.value, 0x00000200);
expect(color[300].value, 0x00000300); expect(color[300]!.value, 0x00000300);
expect(color[400].value, 0x00000400); expect(color[400]!.value, 0x00000400);
expect(color[500].value, 0x00000500); expect(color[500]!.value, 0x00000500);
expect(color[600].value, 0x00000600); expect(color[600]!.value, 0x00000600);
expect(color[700].value, 0x00000700); expect(color[700]!.value, 0x00000700);
expect(color[800].value, 0x00000800); expect(color[800]!.value, 0x00000800);
expect(color[900].value, 0x00000900); expect(color[900]!.value, 0x00000900);
expect(color.shade50.value, 0x00000050); expect(color.shade50.value, 0x00000050);
expect(color.shade100.value, 0x00000100); expect(color.shade100.value, 0x00000100);
...@@ -56,31 +54,31 @@ void main() { ...@@ -56,31 +54,31 @@ void main() {
test('Colors swatches do not contain duplicates', () { test('Colors swatches do not contain duplicates', () {
for (final MaterialColor color in Colors.primaries) for (final MaterialColor color in Colors.primaries)
expect(primaryKeys.map<Color>((int key) => color[key]).toSet().length, primaryKeys.length); expect(primaryKeys.map<Color>((int key) => color[key]!).toSet().length, primaryKeys.length);
expect(primaryKeys.map<Color>((int key) => Colors.grey[key]).toSet().length, primaryKeys.length); expect(primaryKeys.map<Color>((int key) => Colors.grey[key]!).toSet().length, primaryKeys.length);
for (final MaterialAccentColor color in Colors.accents) for (final MaterialAccentColor color in Colors.accents)
expect(accentKeys.map<Color>((int key) => color[key]).toSet().length, accentKeys.length); expect(accentKeys.map<Color>((int key) => color[key]!).toSet().length, accentKeys.length);
}); });
test('All color swatch colors are opaque and equal their primary color', () { test('All color swatch colors are opaque and equal their primary color', () {
for (final MaterialColor color in Colors.primaries) { for (final MaterialColor color in Colors.primaries) {
expect(color.value, color.shade500.value); expect(color.value, color.shade500.value);
for (final int key in primaryKeys) { for (final int key in primaryKeys) {
expect(color[key].alpha, 0xFF); expect(color[key]!.alpha, 0xFF);
} }
} }
expect(Colors.grey.value, Colors.grey.shade500.value); expect(Colors.grey.value, Colors.grey.shade500.value);
for (final int key in primaryKeys) { for (final int key in primaryKeys) {
expect(Colors.grey[key].alpha, 0xFF); expect(Colors.grey[key]!.alpha, 0xFF);
} }
for (final MaterialAccentColor color in Colors.accents) { for (final MaterialAccentColor color in Colors.accents) {
expect(color.value, color.shade200.value); expect(color.value, color.shade200.value);
for (final int key in accentKeys) { for (final int key in accentKeys) {
expect(color[key].alpha, 0xFF); expect(color[key]!.alpha, 0xFF);
} }
} }
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -18,11 +16,11 @@ void main() { ...@@ -18,11 +16,11 @@ void main() {
testWidgets('DataTable control test', (WidgetTester tester) async { testWidgets('DataTable control test', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
Widget buildTable({ int sortColumnIndex, bool sortAscending = true }) { Widget buildTable({ int? sortColumnIndex, bool sortAscending = true }) {
return DataTable( return DataTable(
sortColumnIndex: sortColumnIndex, sortColumnIndex: sortColumnIndex,
sortAscending: sortAscending, sortAscending: sortAscending,
onSelectAll: (bool value) { onSelectAll: (bool? value) {
log.add('select-all: $value'); log.add('select-all: $value');
}, },
columns: <DataColumn>[ columns: <DataColumn>[
...@@ -42,7 +40,7 @@ void main() { ...@@ -42,7 +40,7 @@ void main() {
rows: kDesserts.map<DataRow>((Dessert dessert) { rows: kDesserts.map<DataRow>((Dessert dessert) {
return DataRow( return DataRow(
key: ValueKey<String>(dessert.name), key: ValueKey<String>(dessert.name),
onSelectChanged: (bool selected) { onSelectChanged: (bool? selected) {
log.add('row-selected: ${dessert.name}'); log.add('row-selected: ${dessert.name}');
}, },
cells: <DataCell>[ cells: <DataCell>[
...@@ -112,7 +110,7 @@ void main() { ...@@ -112,7 +110,7 @@ void main() {
Widget buildTable({ bool checkboxes = false }) { Widget buildTable({ bool checkboxes = false }) {
return DataTable( return DataTable(
showCheckboxColumn: checkboxes, showCheckboxColumn: checkboxes,
onSelectAll: (bool value) { onSelectAll: (bool? value) {
log.add('select-all: $value'); log.add('select-all: $value');
}, },
columns: const <DataColumn>[ columns: const <DataColumn>[
...@@ -129,7 +127,7 @@ void main() { ...@@ -129,7 +127,7 @@ void main() {
rows: kDesserts.map<DataRow>((Dessert dessert) { rows: kDesserts.map<DataRow>((Dessert dessert) {
return DataRow( return DataRow(
key: ValueKey<String>(dessert.name), key: ValueKey<String>(dessert.name),
onSelectChanged: (bool selected) { onSelectChanged: (bool? selected) {
log.add('row-selected: ${dessert.name}'); log.add('row-selected: ${dessert.name}');
}, },
cells: <DataCell>[ cells: <DataCell>[
...@@ -395,7 +393,7 @@ void main() { ...@@ -395,7 +393,7 @@ void main() {
testWidgets('DataTable custom row height', (WidgetTester tester) async { testWidgets('DataTable custom row height', (WidgetTester tester) async {
Widget buildCustomTable({ Widget buildCustomTable({
int sortColumnIndex, int? sortColumnIndex,
bool sortAscending = true, bool sortAscending = true,
double dataRowHeight = 48.0, double dataRowHeight = 48.0,
double headingRowHeight = 56.0, double headingRowHeight = 56.0,
...@@ -403,7 +401,7 @@ void main() { ...@@ -403,7 +401,7 @@ void main() {
return DataTable( return DataTable(
sortColumnIndex: sortColumnIndex, sortColumnIndex: sortColumnIndex,
sortAscending: sortAscending, sortAscending: sortAscending,
onSelectAll: (bool value) {}, onSelectAll: (bool? value) {},
dataRowHeight: dataRowHeight, dataRowHeight: dataRowHeight,
headingRowHeight: headingRowHeight, headingRowHeight: headingRowHeight,
columns: <DataColumn>[ columns: <DataColumn>[
...@@ -421,7 +419,7 @@ void main() { ...@@ -421,7 +419,7 @@ void main() {
rows: kDesserts.map<DataRow>((Dessert dessert) { rows: kDesserts.map<DataRow>((Dessert dessert) {
return DataRow( return DataRow(
key: ValueKey<String>(dessert.name), key: ValueKey<String>(dessert.name),
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: <DataCell>[ cells: <DataCell>[
DataCell( DataCell(
Text(dessert.name), Text(dessert.name),
...@@ -441,7 +439,7 @@ void main() { ...@@ -441,7 +439,7 @@ void main() {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Material( home: Material(
child: DataTable( child: DataTable(
onSelectAll: (bool value) {}, onSelectAll: (bool? value) {},
columns: <DataColumn>[ columns: <DataColumn>[
const DataColumn( const DataColumn(
label: Text('Name'), label: Text('Name'),
...@@ -457,7 +455,7 @@ void main() { ...@@ -457,7 +455,7 @@ void main() {
rows: kDesserts.map<DataRow>((Dessert dessert) { rows: kDesserts.map<DataRow>((Dessert dessert) {
return DataRow( return DataRow(
key: ValueKey<String>(dessert.name), key: ValueKey<String>(dessert.name),
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: <DataCell>[ cells: <DataCell>[
DataCell( DataCell(
Text(dessert.name), Text(dessert.name),
...@@ -520,13 +518,13 @@ void main() { ...@@ -520,13 +518,13 @@ void main() {
Finder padding; Finder padding;
Widget buildDefaultTable({ Widget buildDefaultTable({
int sortColumnIndex, int? sortColumnIndex,
bool sortAscending = true, bool sortAscending = true,
}) { }) {
return DataTable( return DataTable(
sortColumnIndex: sortColumnIndex, sortColumnIndex: sortColumnIndex,
sortAscending: sortAscending, sortAscending: sortAscending,
onSelectAll: (bool value) {}, onSelectAll: (bool? value) {},
columns: <DataColumn>[ columns: <DataColumn>[
const DataColumn( const DataColumn(
label: Text('Name'), label: Text('Name'),
...@@ -548,7 +546,7 @@ void main() { ...@@ -548,7 +546,7 @@ void main() {
rows: kDesserts.map<DataRow>((Dessert dessert) { rows: kDesserts.map<DataRow>((Dessert dessert) {
return DataRow( return DataRow(
key: ValueKey<String>(dessert.name), key: ValueKey<String>(dessert.name),
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: <DataCell>[ cells: <DataCell>[
DataCell( DataCell(
Text(dessert.name), Text(dessert.name),
...@@ -623,15 +621,15 @@ void main() { ...@@ -623,15 +621,15 @@ void main() {
); );
Widget buildCustomTable({ Widget buildCustomTable({
int sortColumnIndex, int? sortColumnIndex,
bool sortAscending = true, bool sortAscending = true,
double horizontalMargin, double? horizontalMargin,
double columnSpacing, double? columnSpacing,
}) { }) {
return DataTable( return DataTable(
sortColumnIndex: sortColumnIndex, sortColumnIndex: sortColumnIndex,
sortAscending: sortAscending, sortAscending: sortAscending,
onSelectAll: (bool value) {}, onSelectAll: (bool? value) {},
horizontalMargin: horizontalMargin, horizontalMargin: horizontalMargin,
columnSpacing: columnSpacing, columnSpacing: columnSpacing,
columns: <DataColumn>[ columns: <DataColumn>[
...@@ -655,7 +653,7 @@ void main() { ...@@ -655,7 +653,7 @@ void main() {
rows: kDesserts.map<DataRow>((Dessert dessert) { rows: kDesserts.map<DataRow>((Dessert dessert) {
return DataRow( return DataRow(
key: ValueKey<String>(dessert.name), key: ValueKey<String>(dessert.name),
onSelectChanged: (bool selected) {}, onSelectChanged: (bool? selected) {},
cells: <DataCell>[ cells: <DataCell>[
DataCell( DataCell(
Text(dessert.name), Text(dessert.name),
...@@ -742,7 +740,7 @@ void main() { ...@@ -742,7 +740,7 @@ void main() {
Finder padding; Finder padding;
Widget buildDefaultTable({ Widget buildDefaultTable({
int sortColumnIndex, int? sortColumnIndex,
bool sortAscending = true, bool sortAscending = true,
}) { }) {
return DataTable( return DataTable(
...@@ -831,10 +829,10 @@ void main() { ...@@ -831,10 +829,10 @@ void main() {
); );
Widget buildCustomTable({ Widget buildCustomTable({
int sortColumnIndex, int? sortColumnIndex,
bool sortAscending = true, bool sortAscending = true,
double horizontalMargin, double? horizontalMargin,
double columnSpacing, double? columnSpacing,
}) { }) {
return DataTable( return DataTable(
sortColumnIndex: sortColumnIndex, sortColumnIndex: sortColumnIndex,
...@@ -959,7 +957,7 @@ void main() { ...@@ -959,7 +957,7 @@ void main() {
Table table = tester.widget(find.byType(Table)); Table table = tester.widget(find.byType(Table));
TableRow tableRow = table.children.last; TableRow tableRow = table.children.last;
BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration; BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.top.width, 1.0); expect(boxDecoration.border!.top.width, 1.0);
const double thickness = 4.2; const double thickness = 4.2;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -976,7 +974,7 @@ void main() { ...@@ -976,7 +974,7 @@ void main() {
table = tester.widget(find.byType(Table)); table = tester.widget(find.byType(Table));
tableRow = table.children.last; tableRow = table.children.last;
boxDecoration = tableRow.decoration as BoxDecoration; boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.top.width, thickness); expect(boxDecoration.border!.top.width, thickness);
}); });
testWidgets('DataTable set show bottom border', (WidgetTester tester) async { testWidgets('DataTable set show bottom border', (WidgetTester tester) async {
...@@ -1010,7 +1008,7 @@ void main() { ...@@ -1010,7 +1008,7 @@ void main() {
Table table = tester.widget(find.byType(Table)); Table table = tester.widget(find.byType(Table));
TableRow tableRow = table.children.last; TableRow tableRow = table.children.last;
BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration; BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.bottom.width, 1.0); expect(boxDecoration.border!.bottom.width, 1.0);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1025,11 +1023,11 @@ void main() { ...@@ -1025,11 +1023,11 @@ void main() {
table = tester.widget(find.byType(Table)); table = tester.widget(find.byType(Table));
tableRow = table.children.last; tableRow = table.children.last;
boxDecoration = tableRow.decoration as BoxDecoration; boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.bottom.width, 0.0); expect(boxDecoration.border!.bottom.width, 0.0);
}); });
testWidgets('DataTable column heading cell - with and without sorting', (WidgetTester tester) async { testWidgets('DataTable column heading cell - with and without sorting', (WidgetTester tester) async {
Widget buildTable({ int sortColumnIndex, bool sortEnabled = true }) { Widget buildTable({ int? sortColumnIndex, bool sortEnabled = true }) {
return DataTable( return DataTable(
sortColumnIndex: sortColumnIndex, sortColumnIndex: sortColumnIndex,
columns: <DataColumn>[ columns: <DataColumn>[
...@@ -1098,7 +1096,7 @@ void main() { ...@@ -1098,7 +1096,7 @@ void main() {
// Regression test for a bug described in // Regression test for a bug described in
// https://github.com/flutter/flutter/pull/43735#issuecomment-589459947 // https://github.com/flutter/flutter/pull/43735#issuecomment-589459947
// Filed at https://github.com/flutter/flutter/issues/51152 // Filed at https://github.com/flutter/flutter/issues/51152
Widget buildTable({ int sortColumnIndex }) { Widget buildTable({ int? sortColumnIndex }) {
return DataTable( return DataTable(
sortColumnIndex: sortColumnIndex, sortColumnIndex: sortColumnIndex,
columns: <DataColumn>[ columns: <DataColumn>[
...@@ -1208,7 +1206,7 @@ void main() { ...@@ -1208,7 +1206,7 @@ void main() {
cells: const <DataCell>[ cells: const <DataCell>[
DataCell(Text('Content1')), DataCell(Text('Content1')),
], ],
onSelectChanged: (bool value) {}, onSelectChanged: (bool? value) {},
), ),
DataRow( DataRow(
color: MaterialStateProperty.resolveWith<Color>( color: MaterialStateProperty.resolveWith<Color>(
...@@ -1221,7 +1219,7 @@ void main() { ...@@ -1221,7 +1219,7 @@ void main() {
cells: const <DataCell>[ cells: const <DataCell>[
DataCell(Text('Content2')), DataCell(Text('Content2')),
], ],
onSelectChanged: disabled ? null : (bool value) {}, onSelectChanged: disabled ? null : (bool? value) {},
), ),
], ],
), ),
...@@ -1263,7 +1261,7 @@ void main() { ...@@ -1263,7 +1261,7 @@ void main() {
return Colors.transparent; return Colors.transparent;
}, },
), ),
onSelectChanged: (bool value) {}, onSelectChanged: (bool? value) {},
cells: const <DataCell>[ cells: const <DataCell>[
DataCell(Text('Content1')), DataCell(Text('Content1')),
], ],
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -135,15 +133,15 @@ void main() { ...@@ -135,15 +133,15 @@ void main() {
), ),
); );
final TextStyle dataRowTextStyle = tester.renderObject<RenderParagraph>(find.text('Data')).text.style; final TextStyle dataRowTextStyle = tester.renderObject<RenderParagraph>(find.text('Data')).text.style!;
expect(dataRowTextStyle.fontSize, dataTextStyle.fontSize); expect(dataRowTextStyle.fontSize, dataTextStyle.fontSize);
expect(_tableRowBoxDecoration(tester: tester, index: 1).color, dataRowColor.resolve(<MaterialState>{})); expect(_tableRowBoxDecoration(tester: tester, index: 1).color, dataRowColor.resolve(<MaterialState>{}));
expect(_tableRowBoxDecoration(tester: tester, index: 1).border.top.width, dividerThickness); expect(_tableRowBoxDecoration(tester: tester, index: 1).border!.top.width, dividerThickness);
final Finder dataRowContainer = find.ancestor(of: find.text('Data'), matching: find.byType(Container)); final Finder dataRowContainer = find.ancestor(of: find.text('Data'), matching: find.byType(Container));
expect(tester.getSize(dataRowContainer).height, dataRowHeight); expect(tester.getSize(dataRowContainer).height, dataRowHeight);
final TextStyle headingRowTextStyle = tester.renderObject<RenderParagraph>(find.text('A')).text.style; final TextStyle headingRowTextStyle = tester.renderObject<RenderParagraph>(find.text('A')).text.style!;
expect(headingRowTextStyle.fontSize, headingTextStyle.fontSize); expect(headingRowTextStyle.fontSize, headingTextStyle.fontSize);
expect(_tableRowBoxDecoration(tester: tester, index: 0).color, headingRowColor.resolve(<MaterialState>{})); expect(_tableRowBoxDecoration(tester: tester, index: 0).color, headingRowColor.resolve(<MaterialState>{}));
...@@ -226,15 +224,15 @@ void main() { ...@@ -226,15 +224,15 @@ void main() {
), ),
); );
final TextStyle dataRowTextStyle = tester.renderObject<RenderParagraph>(find.text('Data')).text.style; final TextStyle dataRowTextStyle = tester.renderObject<RenderParagraph>(find.text('Data')).text.style!;
expect(dataRowTextStyle.fontSize, dataTextStyle.fontSize); expect(dataRowTextStyle.fontSize, dataTextStyle.fontSize);
expect(_tableRowBoxDecoration(tester: tester, index: 1).color, dataRowColor.resolve(<MaterialState>{})); expect(_tableRowBoxDecoration(tester: tester, index: 1).color, dataRowColor.resolve(<MaterialState>{}));
expect(_tableRowBoxDecoration(tester: tester, index: 1).border.top.width, dividerThickness); expect(_tableRowBoxDecoration(tester: tester, index: 1).border!.top.width, dividerThickness);
final Finder dataRowContainer = find.ancestor(of: find.text('Data'), matching: find.byType(Container)); final Finder dataRowContainer = find.ancestor(of: find.text('Data'), matching: find.byType(Container));
expect(tester.getSize(dataRowContainer).height, dataRowHeight); expect(tester.getSize(dataRowContainer).height, dataRowHeight);
final TextStyle headingRowTextStyle = tester.renderObject<RenderParagraph>(find.text('A')).text.style; final TextStyle headingRowTextStyle = tester.renderObject<RenderParagraph>(find.text('A')).text.style!;
expect(headingRowTextStyle.fontSize, headingTextStyle.fontSize); expect(headingRowTextStyle.fontSize, headingTextStyle.fontSize);
expect(_tableRowBoxDecoration(tester: tester, index: 0).color, headingRowColor.resolve(<MaterialState>{})); expect(_tableRowBoxDecoration(tester: tester, index: 0).color, headingRowColor.resolve(<MaterialState>{}));
...@@ -245,7 +243,7 @@ void main() { ...@@ -245,7 +243,7 @@ void main() {
}); });
} }
BoxDecoration _tableRowBoxDecoration({WidgetTester tester, int index}) { BoxDecoration _tableRowBoxDecoration({required WidgetTester tester, required int index}) {
final Table table = tester.widget(find.byType(Table)); final Table table = tester.widget(find.byType(Table));
final TableRow tableRow = table.children[index]; final TableRow tableRow = table.children[index];
return tableRow.decoration as BoxDecoration; return tableRow.decoration as BoxDecoration;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -12,7 +10,7 @@ import '../rendering/mock_canvas.dart'; ...@@ -12,7 +10,7 @@ import '../rendering/mock_canvas.dart';
import 'feedback_tester.dart'; import 'feedback_tester.dart';
class MockClipboard { class MockClipboard {
Object _clipboardData = <String, dynamic>{ dynamic _clipboardData = <String, dynamic>{
'text': null, 'text': null,
}; };
...@@ -31,21 +29,21 @@ void main() { ...@@ -31,21 +29,21 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
DateTime firstDate; late DateTime firstDate;
DateTime lastDate; late DateTime lastDate;
DateTime initialDate; late DateTime initialDate;
DateTime today; late DateTime today;
SelectableDayPredicate selectableDayPredicate; late SelectableDayPredicate? selectableDayPredicate;
DatePickerEntryMode initialEntryMode; late DatePickerEntryMode initialEntryMode;
DatePickerMode initialCalendarMode; late DatePickerMode initialCalendarMode;
String cancelText; String? cancelText;
String confirmText; String? confirmText;
String errorFormatText; String? errorFormatText;
String errorInvalidText; String? errorInvalidText;
String fieldHintText; String? fieldHintText;
String fieldLabelText; String? fieldLabelText;
String helpText; String? helpText;
final Finder nextMonthIcon = find.byWidgetPredicate((Widget w) => w is IconButton && (w.tooltip?.startsWith('Next month') ?? false)); final Finder nextMonthIcon = find.byWidgetPredicate((Widget w) => w is IconButton && (w.tooltip?.startsWith('Next month') ?? false));
final Finder previousMonthIcon = find.byWidgetPredicate((Widget w) => w is IconButton && (w.tooltip?.startsWith('Previous month') ?? false)); final Finder previousMonthIcon = find.byWidgetPredicate((Widget w) => w is IconButton && (w.tooltip?.startsWith('Previous month') ?? false));
...@@ -88,7 +86,7 @@ void main() { ...@@ -88,7 +86,7 @@ void main() {
Future<void> callback(Future<DateTime> date), Future<void> callback(Future<DateTime> date),
{ TextDirection textDirection = TextDirection.ltr } { TextDirection textDirection = TextDirection.ltr }
) async { ) async {
BuildContext buttonContext; late BuildContext buttonContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Material( home: Material(
child: Builder( child: Builder(
...@@ -123,10 +121,10 @@ void main() { ...@@ -123,10 +121,10 @@ void main() {
fieldHintText: fieldHintText, fieldHintText: fieldHintText,
fieldLabelText: fieldLabelText, fieldLabelText: fieldLabelText,
helpText: helpText, helpText: helpText,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child ?? const SizedBox(),
); );
}, },
); );
...@@ -141,9 +139,9 @@ void main() { ...@@ -141,9 +139,9 @@ void main() {
confirmText = 'yep'; confirmText = 'yep';
helpText = 'help'; helpText = 'help';
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
expect(find.text(cancelText), findsOneWidget); expect(find.text(cancelText!), findsOneWidget);
expect(find.text(confirmText), findsOneWidget); expect(find.text(confirmText!), findsOneWidget);
expect(find.text(helpText), findsOneWidget); expect(find.text(helpText!), findsOneWidget);
}); });
}); });
...@@ -219,10 +217,10 @@ void main() { ...@@ -219,10 +217,10 @@ void main() {
initialDate: DateTime.now(), initialDate: DateTime.now(),
firstDate: DateTime(2018), firstDate: DateTime(2018),
lastDate: DateTime(2030), lastDate: DateTime(2030),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child ?? const SizedBox(),
); );
}, },
); );
...@@ -273,7 +271,7 @@ void main() { ...@@ -273,7 +271,7 @@ void main() {
initialDate: DateTime.now(), initialDate: DateTime.now(),
firstDate: DateTime(2018), firstDate: DateTime(2018),
lastDate: DateTime(2030), lastDate: DateTime(2030),
builder: (BuildContext context, Widget child) => const SizedBox(), builder: (BuildContext context, Widget? child) => const SizedBox(),
); );
}, },
child: const Text('Show Date Picker'), child: const Text('Show Date Picker'),
...@@ -377,10 +375,10 @@ void main() { ...@@ -377,10 +375,10 @@ void main() {
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
firstDate:DateTime(2001, DateTime.january, 1), firstDate:DateTime(2001, DateTime.january, 1),
lastDate: DateTime(2031, DateTime.december, 31), lastDate: DateTime(2031, DateTime.december, 31),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child ?? const SizedBox(),
); );
}, },
); );
...@@ -670,11 +668,11 @@ void main() { ...@@ -670,11 +668,11 @@ void main() {
fieldLabelText = 'label'; fieldLabelText = 'label';
helpText = 'help'; helpText = 'help';
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
expect(find.text(cancelText), findsOneWidget); expect(find.text(cancelText!), findsOneWidget);
expect(find.text(confirmText), findsOneWidget); expect(find.text(confirmText!), findsOneWidget);
expect(find.text(fieldHintText), findsOneWidget); expect(find.text(fieldHintText!), findsOneWidget);
expect(find.text(fieldLabelText), findsOneWidget); expect(find.text(fieldLabelText!), findsOneWidget);
expect(find.text(helpText), findsOneWidget); expect(find.text(helpText!), findsOneWidget);
}); });
}); });
...@@ -697,7 +695,7 @@ void main() { ...@@ -697,7 +695,7 @@ void main() {
testWidgets('Toggle to calendar mode keeps selected date', (WidgetTester tester) async { testWidgets('Toggle to calendar mode keeps selected date', (WidgetTester tester) async {
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
final TextField field = textField(tester); final TextField field = textField(tester);
field.controller.clear(); field.controller!.clear();
await tester.enterText(find.byType(TextField), '12/25/2016'); await tester.enterText(find.byType(TextField), '12/25/2016');
await tester.tap(find.byIcon(Icons.calendar_today)); await tester.tap(find.byIcon(Icons.calendar_today));
...@@ -710,7 +708,7 @@ void main() { ...@@ -710,7 +708,7 @@ void main() {
testWidgets('Entered text returns date', (WidgetTester tester) async { testWidgets('Entered text returns date', (WidgetTester tester) async {
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
final TextField field = textField(tester); final TextField field = textField(tester);
field.controller.clear(); field.controller!.clear();
await tester.enterText(find.byType(TextField), '12/25/2016'); await tester.enterText(find.byType(TextField), '12/25/2016');
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
...@@ -722,15 +720,15 @@ void main() { ...@@ -722,15 +720,15 @@ void main() {
errorFormatText = 'oops'; errorFormatText = 'oops';
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
final TextField field = textField(tester); final TextField field = textField(tester);
field.controller.clear(); field.controller!.clear();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.enterText(find.byType(TextField), '1225'); await tester.enterText(find.byType(TextField), '1225');
expect(find.text(errorFormatText), findsNothing); expect(find.text(errorFormatText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorFormatText), findsOneWidget); expect(find.text(errorFormatText!), findsOneWidget);
}); });
}); });
...@@ -738,16 +736,16 @@ void main() { ...@@ -738,16 +736,16 @@ void main() {
errorFormatText = 'oops'; errorFormatText = 'oops';
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
final TextField field = textField(tester); final TextField field = textField(tester);
field.controller.clear(); field.controller!.clear();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.enterText(find.byType(TextField), '20 days, 3 months, 2003'); await tester.enterText(find.byType(TextField), '20 days, 3 months, 2003');
expect(find.text('20 days, 3 months, 2003'), findsOneWidget); expect(find.text('20 days, 3 months, 2003'), findsOneWidget);
expect(find.text(errorFormatText), findsNothing); expect(find.text(errorFormatText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorFormatText), findsOneWidget); expect(find.text(errorFormatText!), findsOneWidget);
}); });
}); });
...@@ -755,20 +753,20 @@ void main() { ...@@ -755,20 +753,20 @@ void main() {
errorInvalidText = 'oops'; errorInvalidText = 'oops';
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
final TextField field = textField(tester); final TextField field = textField(tester);
field.controller.clear(); field.controller!.clear();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.enterText(find.byType(TextField), '08/10/1969'); await tester.enterText(find.byType(TextField), '08/10/1969');
expect(find.text(errorInvalidText), findsNothing); expect(find.text(errorInvalidText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorInvalidText), findsOneWidget); expect(find.text(errorInvalidText!), findsOneWidget);
}); });
}); });
testWidgets('InputDecorationTheme is honored', (WidgetTester tester) async { testWidgets('InputDecorationTheme is honored', (WidgetTester tester) async {
BuildContext buttonContext; late BuildContext buttonContext;
const InputBorder border = InputBorder.none; const InputBorder border = InputBorder.none;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData.light().copyWith( theme: ThemeData.light().copyWith(
...@@ -883,7 +881,7 @@ void main() { ...@@ -883,7 +881,7 @@ void main() {
group('Haptic feedback', () { group('Haptic feedback', () {
const Duration hapticFeedbackInterval = Duration(milliseconds: 10); const Duration hapticFeedbackInterval = Duration(milliseconds: 10);
FeedbackTester feedback; late FeedbackTester feedback;
setUp(() { setUp(() {
feedback = FeedbackTester(); feedback = FeedbackTester();
...@@ -895,7 +893,7 @@ void main() { ...@@ -895,7 +893,7 @@ void main() {
}); });
tearDown(() { tearDown(() {
feedback?.dispose(); feedback.dispose();
}); });
testWidgets('Selecting date vibrates', (WidgetTester tester) async { testWidgets('Selecting date vibrates', (WidgetTester tester) async {
...@@ -1523,7 +1521,7 @@ class _DatePickerObserver extends NavigatorObserver { ...@@ -1523,7 +1521,7 @@ class _DatePickerObserver extends NavigatorObserver {
int datePickerCount = 0; int datePickerCount = 0;
@override @override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (route.toString().contains('_DialogRoute')) { if (route.toString().contains('_DialogRoute')) {
datePickerCount++; datePickerCount++;
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -11,23 +9,23 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -11,23 +9,23 @@ import 'package:flutter_test/flutter_test.dart';
import 'feedback_tester.dart'; import 'feedback_tester.dart';
void main() { void main() {
DateTime firstDate; late DateTime firstDate;
DateTime lastDate; late DateTime lastDate;
DateTime currentDate; late DateTime? currentDate;
DateTimeRange initialDateRange; late DateTimeRange? initialDateRange;
DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar; late DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar;
String cancelText; String? cancelText;
String confirmText; String? confirmText;
String errorInvalidRangeText; String? errorInvalidRangeText;
String errorFormatText; String? errorFormatText;
String errorInvalidText; String? errorInvalidText;
String fieldStartHintText; String? fieldStartHintText;
String fieldEndHintText; String? fieldEndHintText;
String fieldStartLabelText; String? fieldStartLabelText;
String fieldEndLabelText; String? fieldEndLabelText;
String helpText; String? helpText;
String saveText; String? saveText;
setUp(() { setUp(() {
firstDate = DateTime(2015, DateTime.january, 1); firstDate = DateTime(2015, DateTime.january, 1);
...@@ -57,7 +55,7 @@ void main() { ...@@ -57,7 +55,7 @@ void main() {
Future<void> callback(Future<DateTimeRange> date), Future<void> callback(Future<DateTimeRange> date),
{ TextDirection textDirection = TextDirection.ltr } { TextDirection textDirection = TextDirection.ltr }
) async { ) async {
BuildContext buttonContext; late BuildContext buttonContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Material( home: Material(
child: Builder( child: Builder(
...@@ -94,10 +92,10 @@ void main() { ...@@ -94,10 +92,10 @@ void main() {
fieldEndLabelText: fieldEndLabelText, fieldEndLabelText: fieldEndLabelText,
helpText: helpText, helpText: helpText,
saveText: saveText, saveText: saveText,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child ?? const SizedBox(),
); );
}, },
); );
...@@ -110,8 +108,8 @@ void main() { ...@@ -110,8 +108,8 @@ void main() {
helpText = 'help'; helpText = 'help';
saveText = 'make it so'; saveText = 'make it so';
await preparePicker(tester, (Future<DateTimeRange> range) async { await preparePicker(tester, (Future<DateTimeRange> range) async {
expect(find.text(helpText), findsOneWidget); expect(find.text(helpText!), findsOneWidget);
expect(find.text(saveText), findsOneWidget); expect(find.text(saveText!), findsOneWidget);
}); });
}); });
...@@ -316,10 +314,10 @@ void main() { ...@@ -316,10 +314,10 @@ void main() {
context: context, context: context,
firstDate:DateTime(2001, DateTime.january, 1), firstDate:DateTime(2001, DateTime.january, 1),
lastDate: DateTime(2031, DateTime.december, 31), lastDate: DateTime(2031, DateTime.december, 31),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child ?? const SizedBox(),
); );
}, },
); );
...@@ -360,7 +358,7 @@ void main() { ...@@ -360,7 +358,7 @@ void main() {
group('Haptic feedback', () { group('Haptic feedback', () {
const Duration hapticFeedbackInterval = Duration(milliseconds: 10); const Duration hapticFeedbackInterval = Duration(milliseconds: 10);
FeedbackTester feedback; late FeedbackTester feedback;
setUp(() { setUp(() {
feedback = FeedbackTester(); feedback = FeedbackTester();
...@@ -373,7 +371,7 @@ void main() { ...@@ -373,7 +371,7 @@ void main() {
}); });
tearDown(() { tearDown(() {
feedback?.dispose(); feedback.dispose();
}); });
testWidgets('Selecting dates vibrates', (WidgetTester tester) async { testWidgets('Selecting dates vibrates', (WidgetTester tester) async {
...@@ -606,13 +604,13 @@ void main() { ...@@ -606,13 +604,13 @@ void main() {
fieldEndLabelText = 'label2'; fieldEndLabelText = 'label2';
helpText = 'help'; helpText = 'help';
await preparePicker(tester, (Future<DateTimeRange> range) async { await preparePicker(tester, (Future<DateTimeRange> range) async {
expect(find.text(cancelText), findsOneWidget); expect(find.text(cancelText!), findsOneWidget);
expect(find.text(confirmText), findsOneWidget); expect(find.text(confirmText!), findsOneWidget);
expect(find.text(fieldStartHintText), findsOneWidget); expect(find.text(fieldStartHintText!), findsOneWidget);
expect(find.text(fieldEndHintText), findsOneWidget); expect(find.text(fieldEndHintText!), findsOneWidget);
expect(find.text(fieldStartLabelText), findsOneWidget); expect(find.text(fieldStartLabelText!), findsOneWidget);
expect(find.text(fieldEndLabelText), findsOneWidget); expect(find.text(fieldEndLabelText!), findsOneWidget);
expect(find.text(helpText), findsOneWidget); expect(find.text(helpText!), findsOneWidget);
}); });
}); });
...@@ -671,11 +669,11 @@ void main() { ...@@ -671,11 +669,11 @@ void main() {
await preparePicker(tester, (Future<DateTimeRange> range) async { await preparePicker(tester, (Future<DateTimeRange> range) async {
await tester.enterText(find.byType(TextField).at(0), '12/25'); await tester.enterText(find.byType(TextField).at(0), '12/25');
await tester.enterText(find.byType(TextField).at(1), '12/25'); await tester.enterText(find.byType(TextField).at(1), '12/25');
expect(find.text(errorFormatText), findsNothing); expect(find.text(errorFormatText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorFormatText), findsNWidgets(2)); expect(find.text(errorFormatText!), findsNWidgets(2));
}); });
}); });
...@@ -685,11 +683,11 @@ void main() { ...@@ -685,11 +683,11 @@ void main() {
await preparePicker(tester, (Future<DateTimeRange> range) async { await preparePicker(tester, (Future<DateTimeRange> range) async {
await tester.enterText(find.byType(TextField).at(0), '20202014'); await tester.enterText(find.byType(TextField).at(0), '20202014');
await tester.enterText(find.byType(TextField).at(1), '20212014'); await tester.enterText(find.byType(TextField).at(1), '20212014');
expect(find.text(errorFormatText), findsNothing); expect(find.text(errorFormatText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorFormatText), findsNWidgets(2)); expect(find.text(errorFormatText!), findsNWidgets(2));
}); });
}); });
...@@ -699,11 +697,11 @@ void main() { ...@@ -699,11 +697,11 @@ void main() {
await preparePicker(tester, (Future<DateTimeRange> range) async { await preparePicker(tester, (Future<DateTimeRange> range) async {
await tester.enterText(find.byType(TextField).at(0), '08/08/2014'); await tester.enterText(find.byType(TextField).at(0), '08/08/2014');
await tester.enterText(find.byType(TextField).at(1), '08/08/2014'); await tester.enterText(find.byType(TextField).at(1), '08/08/2014');
expect(find.text(errorInvalidText), findsNothing); expect(find.text(errorInvalidText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorInvalidText), findsNWidgets(2)); expect(find.text(errorInvalidText!), findsNWidgets(2));
}); });
}); });
...@@ -713,11 +711,11 @@ void main() { ...@@ -713,11 +711,11 @@ void main() {
await preparePicker(tester, (Future<DateTimeRange> range) async { await preparePicker(tester, (Future<DateTimeRange> range) async {
await tester.enterText(find.byType(TextField).at(0), '12/27/2016'); await tester.enterText(find.byType(TextField).at(0), '12/27/2016');
await tester.enterText(find.byType(TextField).at(1), '12/25/2016'); await tester.enterText(find.byType(TextField).at(1), '12/25/2016');
expect(find.text(errorInvalidRangeText), findsNothing); expect(find.text(errorInvalidRangeText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorInvalidRangeText), findsOneWidget); expect(find.text(errorInvalidRangeText!), findsOneWidget);
}); });
}); });
...@@ -727,11 +725,11 @@ void main() { ...@@ -727,11 +725,11 @@ void main() {
await preparePicker(tester, (Future<DateTimeRange> range) async { await preparePicker(tester, (Future<DateTimeRange> range) async {
await tester.enterText(find.byType(TextField).at(0), '12/27/2016'); await tester.enterText(find.byType(TextField).at(0), '12/27/2016');
await tester.enterText(find.byType(TextField).at(1), '01/01/2018'); await tester.enterText(find.byType(TextField).at(1), '01/01/2018');
expect(find.text(errorInvalidText), findsNothing); expect(find.text(errorInvalidText!), findsNothing);
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text(errorInvalidText), findsOneWidget); expect(find.text(errorInvalidText!), findsOneWidget);
}); });
}); });
...@@ -768,7 +766,7 @@ void main() { ...@@ -768,7 +766,7 @@ void main() {
expect(containerColor, equals(expectedContainerColor)); expect(containerColor, equals(expectedContainerColor));
} }
BuildContext buttonContext; late BuildContext buttonContext;
const InputBorder border = InputBorder.none; const InputBorder border = InputBorder.none;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData.light().copyWith( theme: ThemeData.light().copyWith(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -231,12 +229,12 @@ void main() { ...@@ -231,12 +229,12 @@ void main() {
) )
)); ));
final List<dynamic> exceptions = <dynamic>[]; final List<dynamic> exceptions = <dynamic>[];
final FlutterExceptionHandler oldHandler = FlutterError.onError; final FlutterExceptionHandler? oldHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) { FlutterError.onError = (FlutterErrorDetails details) {
exceptions.add(details.exception); exceptions.add(details.exception);
}; };
// ScaffoldMessenger shows SnackBar. // ScaffoldMessenger shows SnackBar.
_scaffoldMessengerKey.currentState.showSnackBar(snackBar); _scaffoldMessengerKey.currentState!.showSnackBar(snackBar);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Pump widget to rebuild without ScaffoldMessenger // Pump widget to rebuild without ScaffoldMessenger
......
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