mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
more const immutable classes (#104988)
* more const immutable classes * more const constructors in dev/ and examples/
This commit is contained in:
parent
16b7348155
commit
552c50e67c
@ -19,6 +19,8 @@ enum _StockMenuItem { autorefresh, refresh, speedUp, speedDown }
|
|||||||
enum StockHomeTab { market, portfolio }
|
enum StockHomeTab { market, portfolio }
|
||||||
|
|
||||||
class _NotImplementedDialog extends StatelessWidget {
|
class _NotImplementedDialog extends StatelessWidget {
|
||||||
|
const _NotImplementedDialog();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
@ -97,7 +99,7 @@ class StockHomeState extends State<StockHome> {
|
|||||||
case _StockMenuItem.refresh:
|
case _StockMenuItem.refresh:
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) => _NotImplementedDialog(),
|
builder: (BuildContext context) => const _NotImplementedDialog(),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case _StockMenuItem.speedUp:
|
case _StockMenuItem.speedUp:
|
||||||
@ -303,7 +305,7 @@ class StockHomeState extends State<StockHome> {
|
|||||||
void _handleCreateCompany() {
|
void _handleCreateCompany() {
|
||||||
showModalBottomSheet<void>(
|
showModalBottomSheet<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) => _CreateCompanySheet(),
|
builder: (BuildContext context) => const _CreateCompanySheet(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,6 +341,8 @@ class StockHomeState extends State<StockHome> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _CreateCompanySheet extends StatelessWidget {
|
class _CreateCompanySheet extends StatelessWidget {
|
||||||
|
const _CreateCompanySheet();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
|
@ -214,7 +214,7 @@ class _CustomValueIndicatorShape extends SliderComponentShape {
|
|||||||
class _SliderDemoState extends State<SliderDemo> {
|
class _SliderDemoState extends State<SliderDemo> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[
|
const List<ComponentDemoTabData> demos = <ComponentDemoTabData>[
|
||||||
ComponentDemoTabData(
|
ComponentDemoTabData(
|
||||||
tabName: 'SINGLE',
|
tabName: 'SINGLE',
|
||||||
description: 'Sliders containing 1 thumb',
|
description: 'Sliders containing 1 thumb',
|
||||||
@ -229,7 +229,7 @@ class _SliderDemoState extends State<SliderDemo> {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
return TabbedComponentDemoScaffold(
|
return const TabbedComponentDemoScaffold(
|
||||||
title: 'Sliders',
|
title: 'Sliders',
|
||||||
demos: demos,
|
demos: demos,
|
||||||
isScrollable: false,
|
isScrollable: false,
|
||||||
@ -239,6 +239,8 @@ class _SliderDemoState extends State<SliderDemo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _Sliders extends StatefulWidget {
|
class _Sliders extends StatefulWidget {
|
||||||
|
const _Sliders();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SlidersState createState() => _SlidersState();
|
_SlidersState createState() => _SlidersState();
|
||||||
}
|
}
|
||||||
@ -357,6 +359,8 @@ class _SlidersState extends State<_Sliders> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RangeSliders extends StatefulWidget {
|
class _RangeSliders extends StatefulWidget {
|
||||||
|
const _RangeSliders();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_RangeSlidersState createState() => _RangeSlidersState();
|
_RangeSlidersState createState() => _RangeSlidersState();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,8 @@ class MyApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ListTileCursor extends MaterialStateMouseCursor {
|
class ListTileCursor extends MaterialStateMouseCursor {
|
||||||
|
const ListTileCursor();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MouseCursor resolve(Set<MaterialState> states) {
|
MouseCursor resolve(Set<MaterialState> states) {
|
||||||
if (states.contains(MaterialState.disabled)) {
|
if (states.contains(MaterialState.disabled)) {
|
||||||
@ -45,8 +47,8 @@ class MyStatelessWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return const ListTile(
|
||||||
title: const Text('Disabled ListTile'),
|
title: Text('Disabled ListTile'),
|
||||||
enabled: false,
|
enabled: false,
|
||||||
mouseCursor: ListTileCursor(),
|
mouseCursor: ListTileCursor(),
|
||||||
);
|
);
|
||||||
|
@ -24,6 +24,8 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
class SelectedBorder extends RoundedRectangleBorder
|
class SelectedBorder extends RoundedRectangleBorder
|
||||||
implements MaterialStateOutlinedBorder {
|
implements MaterialStateOutlinedBorder {
|
||||||
|
const SelectedBorder();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
OutlinedBorder? resolve(Set<MaterialState> states) {
|
OutlinedBorder? resolve(Set<MaterialState> states) {
|
||||||
if (states.contains(MaterialState.selected)) {
|
if (states.contains(MaterialState.selected)) {
|
||||||
@ -54,7 +56,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
|||||||
isSelected = value;
|
isSelected = value;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
shape: SelectedBorder(),
|
shape: const SelectedBorder(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,15 @@ class IVBuilderExampleApp extends StatelessWidget {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('IV Builder Example'),
|
title: const Text('IV Builder Example'),
|
||||||
),
|
),
|
||||||
body: _IVBuilderExample(),
|
body: const _IVBuilderExample(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IVBuilderExample extends StatefulWidget {
|
class _IVBuilderExample extends StatefulWidget {
|
||||||
|
const _IVBuilderExample();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_IVBuilderExample> createState() => _IVBuilderExampleState();
|
State<_IVBuilderExample> createState() => _IVBuilderExampleState();
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ enum _CupertinoTextSelectionToolbarItemsSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NullElement extends Element {
|
class _NullElement extends Element {
|
||||||
_NullElement() : super(_NullWidget());
|
_NullElement() : super(const _NullWidget());
|
||||||
|
|
||||||
static _NullElement instance = _NullElement();
|
static _NullElement instance = _NullElement();
|
||||||
|
|
||||||
@ -1021,6 +1021,8 @@ class _NullElement extends Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NullWidget extends Widget {
|
class _NullWidget extends Widget {
|
||||||
|
const _NullWidget();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Element createElement() => throw UnimplementedError();
|
Element createElement() => throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
@ -1751,7 +1751,7 @@ class _CalendarDateRangePickerState extends State<_CalendarDateRangePicker> {
|
|||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
_DayHeaders(),
|
const _DayHeaders(),
|
||||||
if (_showWeekBottomDivider) const Divider(height: 0),
|
if (_showWeekBottomDivider) const Divider(height: 0),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _CalendarKeyboardNavigator(
|
child: _CalendarKeyboardNavigator(
|
||||||
@ -1947,6 +1947,8 @@ class _FocusedDate extends InheritedWidget {
|
|||||||
|
|
||||||
|
|
||||||
class _DayHeaders extends StatelessWidget {
|
class _DayHeaders extends StatelessWidget {
|
||||||
|
const _DayHeaders();
|
||||||
|
|
||||||
/// Builds widgets showing abbreviated days of week. The first widget in the
|
/// Builds widgets showing abbreviated days of week. The first widget in the
|
||||||
/// returned list corresponds to the first day of week for the current locale.
|
/// returned list corresponds to the first day of week for the current locale.
|
||||||
///
|
///
|
||||||
|
@ -1451,7 +1451,10 @@ class ButtonActivateIntent extends Intent {
|
|||||||
abstract class ActivateAction extends Action<ActivateIntent> { }
|
abstract class ActivateAction extends Action<ActivateIntent> { }
|
||||||
|
|
||||||
/// An [Intent] that selects the currently focused control.
|
/// An [Intent] that selects the currently focused control.
|
||||||
class SelectIntent extends Intent { }
|
class SelectIntent extends Intent {
|
||||||
|
/// Creates an intent that selects the currently focused control.
|
||||||
|
const SelectIntent();
|
||||||
|
}
|
||||||
|
|
||||||
/// An action that selects the currently focused control.
|
/// An action that selects the currently focused control.
|
||||||
///
|
///
|
||||||
|
@ -1919,7 +1919,7 @@ mixin WidgetInspectorService {
|
|||||||
///
|
///
|
||||||
/// {@macro flutter.widgets.WidgetInspectorService.getChildrenSummaryTree}
|
/// {@macro flutter.widgets.WidgetInspectorService.getChildrenSummaryTree}
|
||||||
bool isWidgetCreationTracked() {
|
bool isWidgetCreationTracked() {
|
||||||
_widgetCreationTracked ??= _WidgetForTypeTests() is _HasCreationLocation;
|
_widgetCreationTracked ??= const _WidgetForTypeTests() is _HasCreationLocation;
|
||||||
return _widgetCreationTracked!;
|
return _widgetCreationTracked!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2190,6 +2190,8 @@ class _ElementLocationStatsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _WidgetForTypeTests extends Widget {
|
class _WidgetForTypeTests extends Widget {
|
||||||
|
const _WidgetForTypeTests();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Element createElement() => throw UnimplementedError();
|
Element createElement() => throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import '../scheduler/scheduler_tester.dart';
|
import '../scheduler/scheduler_tester.dart';
|
||||||
|
|
||||||
class BogusCurve extends Curve {
|
class BogusCurve extends Curve {
|
||||||
|
const BogusCurve();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double transform(double t) => 100.0;
|
double transform(double t) => 100.0;
|
||||||
}
|
}
|
||||||
@ -234,7 +236,7 @@ void main() {
|
|||||||
final AnimationController controller = AnimationController(
|
final AnimationController controller = AnimationController(
|
||||||
vsync: const TestVSync(),
|
vsync: const TestVSync(),
|
||||||
);
|
);
|
||||||
final CurvedAnimation curved = CurvedAnimation(parent: controller, curve: BogusCurve());
|
final CurvedAnimation curved = CurvedAnimation(parent: controller, curve: const BogusCurve());
|
||||||
FlutterError? error;
|
FlutterError? error;
|
||||||
try {
|
try {
|
||||||
curved.value;
|
curved.value;
|
||||||
|
@ -585,7 +585,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NullElement extends Element {
|
class _NullElement extends Element {
|
||||||
_NullElement() : super(_NullWidget());
|
_NullElement() : super(const _NullWidget());
|
||||||
|
|
||||||
static _NullElement instance = _NullElement();
|
static _NullElement instance = _NullElement();
|
||||||
|
|
||||||
@ -597,6 +597,8 @@ class _NullElement extends Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NullWidget extends Widget {
|
class _NullWidget extends Widget {
|
||||||
|
const _NullWidget();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Element createElement() => throw UnimplementedError();
|
Element createElement() => throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1233,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('CupertinoDialogRoute is state restorable', (WidgetTester tester) async {
|
testWidgets('CupertinoDialogRoute is state restorable', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
CupertinoApp(
|
const CupertinoApp(
|
||||||
restorationScopeId: 'app',
|
restorationScopeId: 'app',
|
||||||
home: _RestorableDialogTestWidget(),
|
home: _RestorableDialogTestWidget(),
|
||||||
),
|
),
|
||||||
@ -1546,6 +1546,8 @@ Widget createAppWithCenteredButton(Widget child) {
|
|||||||
|
|
||||||
|
|
||||||
class _RestorableDialogTestWidget extends StatelessWidget {
|
class _RestorableDialogTestWidget extends StatelessWidget {
|
||||||
|
const _RestorableDialogTestWidget();
|
||||||
|
|
||||||
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
|
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
|
||||||
return CupertinoDialogRoute<void>(
|
return CupertinoDialogRoute<void>(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -1790,7 +1790,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Popping routes should cancel down events', (WidgetTester tester) async {
|
testWidgets('Popping routes should cancel down events', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(_TestPostRouteCancel());
|
await tester.pumpWidget(const _TestPostRouteCancel());
|
||||||
|
|
||||||
final TestGesture gesture = await tester.createGesture();
|
final TestGesture gesture = await tester.createGesture();
|
||||||
await gesture.down(tester.getCenter(find.text('PointerCancelEvents: 0')));
|
await gesture.down(tester.getCenter(find.text('PointerCancelEvents: 0')));
|
||||||
@ -1861,7 +1861,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('CupertinoModalPopupRoute is state restorable', (WidgetTester tester) async {
|
testWidgets('CupertinoModalPopupRoute is state restorable', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
CupertinoApp(
|
const CupertinoApp(
|
||||||
restorationScopeId: 'app',
|
restorationScopeId: 'app',
|
||||||
home: _RestorableModalTestWidget(),
|
home: _RestorableModalTestWidget(),
|
||||||
),
|
),
|
||||||
@ -2249,6 +2249,8 @@ Widget buildNavigator({
|
|||||||
// Holding the 'Hold' button at the moment of popping will force the navigator to
|
// Holding the 'Hold' button at the moment of popping will force the navigator to
|
||||||
// cancel the down event, increasing the Home counter by 1.
|
// cancel the down event, increasing the Home counter by 1.
|
||||||
class _TestPostRouteCancel extends StatefulWidget {
|
class _TestPostRouteCancel extends StatefulWidget {
|
||||||
|
const _TestPostRouteCancel();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _TestPostRouteCancelState();
|
State<StatefulWidget> createState() => _TestPostRouteCancelState();
|
||||||
}
|
}
|
||||||
@ -2308,6 +2310,8 @@ class _TestPostRouteCancelState extends State<_TestPostRouteCancel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RestorableModalTestWidget extends StatelessWidget {
|
class _RestorableModalTestWidget extends StatelessWidget {
|
||||||
|
const _RestorableModalTestWidget();
|
||||||
|
|
||||||
static Route<void> _modalBuilder(BuildContext context, Object? arguments) {
|
static Route<void> _modalBuilder(BuildContext context, Object? arguments) {
|
||||||
return CupertinoModalPopupRoute<void>(
|
return CupertinoModalPopupRoute<void>(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
@ -2212,7 +2212,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('DialogRoute is state restorable', (WidgetTester tester) async {
|
testWidgets('DialogRoute is state restorable', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
const MaterialApp(
|
||||||
restorationScopeId: 'app',
|
restorationScopeId: 'app',
|
||||||
home: _RestorableDialogTestWidget(),
|
home: _RestorableDialogTestWidget(),
|
||||||
),
|
),
|
||||||
@ -2294,6 +2294,8 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RestorableDialogTestWidget extends StatelessWidget {
|
class _RestorableDialogTestWidget extends StatelessWidget {
|
||||||
|
const _RestorableDialogTestWidget();
|
||||||
|
|
||||||
static Route<Object?> _materialDialogBuilder(BuildContext context, Object? arguments) {
|
static Route<Object?> _materialDialogBuilder(BuildContext context, Object? arguments) {
|
||||||
return DialogRoute<void>(
|
return DialogRoute<void>(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -167,7 +167,7 @@ void main() {
|
|||||||
// We create the geometry listener here, but it can only be set up
|
// We create the geometry listener here, but it can only be set up
|
||||||
// after it is pumped into the widget tree and a tester is
|
// after it is pumped into the widget tree and a tester is
|
||||||
// available.
|
// available.
|
||||||
geometryListener = _GeometryListener();
|
geometryListener = const _GeometryListener();
|
||||||
geometry = null;
|
geometry = null;
|
||||||
listenerState = null;
|
listenerState = null;
|
||||||
previousRect = null;
|
previousRect = null;
|
||||||
@ -1516,6 +1516,8 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _GeometryListener extends StatefulWidget {
|
class _GeometryListener extends StatefulWidget {
|
||||||
|
const _GeometryListener();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State createState() => _GeometryListenerState();
|
State createState() => _GeometryListenerState();
|
||||||
}
|
}
|
||||||
|
@ -1236,7 +1236,7 @@ void main() {
|
|||||||
bottomNavigationBar: ConstrainedBox(
|
bottomNavigationBar: ConstrainedBox(
|
||||||
key: key,
|
key: key,
|
||||||
constraints: const BoxConstraints.expand(height: 80.0),
|
constraints: const BoxConstraints.expand(height: 80.0),
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -1255,7 +1255,7 @@ void main() {
|
|||||||
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
||||||
body: ConstrainedBox(
|
body: ConstrainedBox(
|
||||||
constraints: const BoxConstraints.expand(height: 80.0),
|
constraints: const BoxConstraints.expand(height: 80.0),
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -1337,7 +1337,7 @@ void main() {
|
|||||||
body: Container(),
|
body: Container(),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
key: key,
|
key: key,
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
onPressed: () { },
|
onPressed: () { },
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
@ -1358,7 +1358,7 @@ void main() {
|
|||||||
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
||||||
body: ConstrainedBox(
|
body: ConstrainedBox(
|
||||||
constraints: const BoxConstraints.expand(height: 80.0),
|
constraints: const BoxConstraints.expand(height: 80.0),
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -1376,7 +1376,7 @@ void main() {
|
|||||||
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
||||||
body: ConstrainedBox(
|
body: ConstrainedBox(
|
||||||
constraints: const BoxConstraints.expand(height: 80.0),
|
constraints: const BoxConstraints.expand(height: 80.0),
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -1384,7 +1384,7 @@ void main() {
|
|||||||
body: Container(),
|
body: Container(),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
key: key,
|
key: key,
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
onPressed: () { },
|
onPressed: () { },
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
@ -1439,7 +1439,7 @@ void main() {
|
|||||||
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
await tester.pumpWidget(MaterialApp(home: Scaffold(
|
||||||
body: ConstrainedBox(
|
body: ConstrainedBox(
|
||||||
constraints: const BoxConstraints.expand(height: 80.0),
|
constraints: const BoxConstraints.expand(height: 80.0),
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -1452,7 +1452,7 @@ void main() {
|
|||||||
body: Container(),
|
body: Container(),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
key: key,
|
key: key,
|
||||||
child: _GeometryListener(),
|
child: const _GeometryListener(),
|
||||||
onPressed: () { },
|
onPressed: () { },
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
@ -2424,6 +2424,8 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _GeometryListener extends StatefulWidget {
|
class _GeometryListener extends StatefulWidget {
|
||||||
|
const _GeometryListener();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_GeometryListenerState createState() => _GeometryListenerState();
|
_GeometryListenerState createState() => _GeometryListenerState();
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ void main() {
|
|||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: Navigator(
|
body: Navigator(
|
||||||
pages: <Page<void>>[_APage(), _BPage()],
|
pages: const <Page<void>>[_APage(), _BPage()],
|
||||||
onPopPage: (Route<dynamic> route, dynamic result) {
|
onPopPage: (Route<dynamic> route, dynamic result) {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@ -551,6 +551,8 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _APage extends Page<void> {
|
class _APage extends Page<void> {
|
||||||
|
const _APage();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Route<void> createRoute(BuildContext context) => PageRouteBuilder<void>(
|
Route<void> createRoute(BuildContext context) => PageRouteBuilder<void>(
|
||||||
settings: this,
|
settings: this,
|
||||||
@ -559,6 +561,8 @@ class _APage extends Page<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BPage extends Page<void> {
|
class _BPage extends Page<void> {
|
||||||
|
const _BPage();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Route<void> createRoute(BuildContext context) => PageRouteBuilder<void>(
|
Route<void> createRoute(BuildContext context) => PageRouteBuilder<void>(
|
||||||
settings: this,
|
settings: this,
|
||||||
|
@ -9,6 +9,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import '../rendering/mock_canvas.dart';
|
import '../rendering/mock_canvas.dart';
|
||||||
|
|
||||||
class SillyBorder extends BoxBorder {
|
class SillyBorder extends BoxBorder {
|
||||||
|
const SillyBorder();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
dynamic noSuchMethod(Invocation invocation) => null;
|
dynamic noSuchMethod(Invocation invocation) => null;
|
||||||
}
|
}
|
||||||
@ -53,7 +55,7 @@ void main() {
|
|||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, -1.0), const Border(top: BorderSide(color: Color(0xFFFFFF00), width: 5.0)));
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, -1.0), const Border(top: BorderSide(color: Color(0xFFFFFF00), width: 5.0)));
|
||||||
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, -1.0), visualWithSides30);
|
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, -1.0), visualWithSides30);
|
||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, -1.0), directionalWithYellowTop10);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, -1.0), directionalWithYellowTop10);
|
||||||
expect(() => BoxBorder.lerp(SillyBorder(), const Border(), -1.0), throwsFlutterError);
|
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), -1.0), throwsFlutterError);
|
||||||
|
|
||||||
expect(BoxBorder.lerp(null, null, 0.0), null);
|
expect(BoxBorder.lerp(null, null, 0.0), null);
|
||||||
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.0), Border.all(width: 10.0));
|
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.0), Border.all(width: 10.0));
|
||||||
@ -65,7 +67,7 @@ void main() {
|
|||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.0), const Border(top: BorderSide(color: Color(0xFFFFFF00), width: 5.0)));
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.0), const Border(top: BorderSide(color: Color(0xFFFFFF00), width: 5.0)));
|
||||||
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.0), visualWithSides10);
|
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.0), visualWithSides10);
|
||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.0), directionalWithYellowTop5);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.0), directionalWithYellowTop5);
|
||||||
expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.0), throwsFlutterError);
|
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), 0.0), throwsFlutterError);
|
||||||
|
|
||||||
expect(BoxBorder.lerp(null, null, 0.25), null);
|
expect(BoxBorder.lerp(null, null, 0.25), null);
|
||||||
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.25), Border.all(width: 7.5));
|
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.25), Border.all(width: 7.5));
|
||||||
@ -77,7 +79,7 @@ void main() {
|
|||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.25), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.25)!)));
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.25), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.25)!)));
|
||||||
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.25), visualWithSides10At50);
|
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.25), visualWithSides10At50);
|
||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.25), visualWithYellowTop5At75 + directionalWithSides10At25);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.25), visualWithYellowTop5At75 + directionalWithSides10At25);
|
||||||
expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.25), throwsFlutterError);
|
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), 0.25), throwsFlutterError);
|
||||||
|
|
||||||
expect(BoxBorder.lerp(null, null, 0.75), null);
|
expect(BoxBorder.lerp(null, null, 0.75), null);
|
||||||
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.75), Border.all(width: 2.5));
|
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.75), Border.all(width: 2.5));
|
||||||
@ -89,7 +91,7 @@ void main() {
|
|||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.75), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.75)!)));
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.75), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.75)!)));
|
||||||
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.75), directionalWithSides10At50);
|
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.75), directionalWithSides10At50);
|
||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.75), visualWithYellowTop5At25 + directionalWithSides10At75);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.75), visualWithYellowTop5At25 + directionalWithSides10At75);
|
||||||
expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.75), throwsFlutterError);
|
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), 0.75), throwsFlutterError);
|
||||||
|
|
||||||
expect(BoxBorder.lerp(null, null, 1.0), null);
|
expect(BoxBorder.lerp(null, null, 1.0), null);
|
||||||
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 1.0), Border.all(width: 0.0, style: BorderStyle.none));
|
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 1.0), Border.all(width: 0.0, style: BorderStyle.none));
|
||||||
@ -101,7 +103,7 @@ void main() {
|
|||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 1.0), visualWithMagentaTop5);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 1.0), visualWithMagentaTop5);
|
||||||
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 1.0), directionalWithSides10);
|
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 1.0), directionalWithSides10);
|
||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 1.0), directionalWithSides10);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 1.0), directionalWithSides10);
|
||||||
expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 1.0), throwsFlutterError);
|
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), 1.0), throwsFlutterError);
|
||||||
|
|
||||||
expect(BoxBorder.lerp(null, null, 2.0), null);
|
expect(BoxBorder.lerp(null, null, 2.0), null);
|
||||||
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 2.0), Border.all(width: 0.0, style: BorderStyle.none));
|
expect(BoxBorder.lerp(Border.all(width: 10.0), null, 2.0), Border.all(width: 0.0, style: BorderStyle.none));
|
||||||
@ -113,13 +115,13 @@ void main() {
|
|||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 2.0), visualWithMagentaTop5);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 2.0), visualWithMagentaTop5);
|
||||||
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 2.0), directionalWithSides30);
|
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 2.0), directionalWithSides30);
|
||||||
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 2.0), directionalWithSides20);
|
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 2.0), directionalWithSides20);
|
||||||
expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 2.0), throwsFlutterError);
|
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), 2.0), throwsFlutterError);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('BoxBorder.lerp throws correct FlutterError message', () {
|
test('BoxBorder.lerp throws correct FlutterError message', () {
|
||||||
late FlutterError error;
|
late FlutterError error;
|
||||||
try {
|
try {
|
||||||
BoxBorder.lerp(SillyBorder(), const Border(), 2.0);
|
BoxBorder.lerp(const SillyBorder(), const Border(), 2.0);
|
||||||
} on FlutterError catch (e) {
|
} on FlutterError catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ void main() {
|
|||||||
size: size,
|
size: size,
|
||||||
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
builderInvocationCount += 1;
|
builderInvocationCount += 1;
|
||||||
return _LayoutSpy();
|
return const _LayoutSpy();
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -681,8 +681,8 @@ void main() {
|
|||||||
final _RenderLayoutSpy spy = tester.renderObject(find.byType(_LayoutSpy));
|
final _RenderLayoutSpy spy = tester.renderObject(find.byType(_LayoutSpy));
|
||||||
childSize = spy.size;
|
childSize = spy.size;
|
||||||
}
|
}
|
||||||
return ColoredBox(
|
return const ColoredBox(
|
||||||
color: const Color(0xffffffff),
|
color: Color(0xffffffff),
|
||||||
child: _LayoutSpy(),
|
child: _LayoutSpy(),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -699,6 +699,8 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LayoutSpy extends LeafRenderObjectWidget {
|
class _LayoutSpy extends LeafRenderObjectWidget {
|
||||||
|
const _LayoutSpy();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
LeafRenderObjectElement createElement() => _LayoutSpyElement(this);
|
LeafRenderObjectElement createElement() => _LayoutSpyElement(this);
|
||||||
|
|
||||||
|
@ -1032,7 +1032,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('detects pointer enter with closure arguments', (WidgetTester tester) async {
|
testWidgets('detects pointer enter with closure arguments', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(_HoverClientWithClosures());
|
await tester.pumpWidget(const _HoverClientWithClosures());
|
||||||
expect(find.text('not hovering'), findsOneWidget);
|
expect(find.text('not hovering'), findsOneWidget);
|
||||||
|
|
||||||
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||||
@ -1896,6 +1896,8 @@ class _DelegatedPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HoverClientWithClosures extends StatefulWidget {
|
class _HoverClientWithClosures extends StatefulWidget {
|
||||||
|
const _HoverClientWithClosures();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_HoverClientWithClosuresState createState() => _HoverClientWithClosuresState();
|
_HoverClientWithClosuresState createState() => _HoverClientWithClosuresState();
|
||||||
}
|
}
|
||||||
|
@ -1949,7 +1949,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('RawDialogRoute is state restorable', (WidgetTester tester) async {
|
testWidgets('RawDialogRoute is state restorable', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
const MaterialApp(
|
||||||
restorationScopeId: 'app',
|
restorationScopeId: 'app',
|
||||||
home: _RestorableDialogTestWidget(),
|
home: _RestorableDialogTestWidget(),
|
||||||
),
|
),
|
||||||
@ -2299,6 +2299,8 @@ class WidgetWithNoLocalHistoryState extends State<WidgetWithNoLocalHistory> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RestorableDialogTestWidget extends StatelessWidget {
|
class _RestorableDialogTestWidget extends StatelessWidget {
|
||||||
|
const _RestorableDialogTestWidget();
|
||||||
|
|
||||||
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
|
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
|
||||||
return RawDialogRoute<void>(
|
return RawDialogRoute<void>(
|
||||||
pageBuilder: (
|
pageBuilder: (
|
||||||
|
@ -67,7 +67,7 @@ void main() {
|
|||||||
|
|
||||||
group('TickerProviderStateMixin assertion control test', () {
|
group('TickerProviderStateMixin assertion control test', () {
|
||||||
testWidgets('SingleTickerProviderStateMixin create multiple tickers', (WidgetTester tester) async {
|
testWidgets('SingleTickerProviderStateMixin create multiple tickers', (WidgetTester tester) async {
|
||||||
final Widget widget = _SingleTickerCreateMultipleTicker();
|
const Widget widget = _SingleTickerCreateMultipleTicker();
|
||||||
await tester.pumpWidget(widget);
|
await tester.pumpWidget(widget);
|
||||||
final dynamic exception = tester.takeException();
|
final dynamic exception = tester.takeException();
|
||||||
expect(exception, isNotNull);
|
expect(exception, isNotNull);
|
||||||
@ -304,6 +304,8 @@ class _MultipleTickerTestState extends State<_MultipleTickerTest> with TickerPro
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SingleTickerCreateMultipleTicker extends StatefulWidget {
|
class _SingleTickerCreateMultipleTicker extends StatefulWidget {
|
||||||
|
const _SingleTickerCreateMultipleTicker();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SingleTickerCreateMultipleTickerState createState() => _SingleTickerCreateMultipleTickerState();
|
_SingleTickerCreateMultipleTickerState createState() => _SingleTickerCreateMultipleTickerState();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user