mirror of
https://github.com/flutter/flutter
synced 2024-10-12 11:12:54 +00:00
Enable avoid_unnecessary_containers lint (#77294)
This commit is contained in:
parent
c5d1600843
commit
ed755fba5e
|
@ -87,7 +87,7 @@ linter:
|
|||
- avoid_type_to_string
|
||||
- avoid_types_as_parameter_names
|
||||
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
|
||||
# - avoid_unnecessary_containers # not yet tested
|
||||
- avoid_unnecessary_containers
|
||||
- avoid_unused_constructor_parameters
|
||||
- avoid_void_async
|
||||
# - avoid_web_libraries_in_flutter # not yet tested
|
||||
|
|
|
@ -551,9 +551,7 @@ class ItemGalleryBox extends StatelessWidget {
|
|||
}).toList(),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: const TabPageSelector(),
|
||||
),
|
||||
const TabPageSelector(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -53,12 +53,10 @@ class TextFieldPage extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
child: Container(
|
||||
child: TextField(
|
||||
maxLines: null,
|
||||
controller: TextEditingController(text: textLotsOfText),
|
||||
key: const Key('fullscreen-textfield'),
|
||||
),
|
||||
child: TextField(
|
||||
maxLines: null,
|
||||
controller: TextEditingController(text: textLotsOfText),
|
||||
key: const Key('fullscreen-textfield'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -23,15 +23,13 @@ class ModalBottomSheetDemo extends StatelessWidget {
|
|||
child: const Text('SHOW BOTTOM SHEET'),
|
||||
onPressed: () {
|
||||
showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: Text('This is the modal bottom sheet. Slide down to dismiss.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).accentColor,
|
||||
fontSize: 24.0,
|
||||
),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: Text('This is the modal bottom sheet. Slide down to dismiss.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).accentColor,
|
||||
fontSize: 24.0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -541,11 +541,9 @@ class ExtraProductsNumber extends StatelessWidget {
|
|||
final int numOverflowProducts = _calculateOverflow(model);
|
||||
// Maximum of 99 so padding doesn't get messy.
|
||||
final int displayedOverflowProducts = numOverflowProducts <= 99 ? numOverflowProducts : 99;
|
||||
return Container(
|
||||
child: Text(
|
||||
'+$displayedOverflowProducts',
|
||||
style: Theme.of(context).primaryTextTheme.button,
|
||||
),
|
||||
return Text(
|
||||
'+$displayedOverflowProducts',
|
||||
style: Theme.of(context).primaryTextTheme.button,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,63 +41,61 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
|
|||
return Scaffold(
|
||||
backgroundColor: kShrinePink50,
|
||||
body: SafeArea(
|
||||
child: Container(
|
||||
child: ScopedModelDescendant<AppStateModel>(
|
||||
builder: (BuildContext context, Widget? child, AppStateModel model) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
ListView(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: _leftColumnWidth,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.keyboard_arrow_down),
|
||||
onPressed: () => ExpandingBottomSheet.of(context)!.close(),
|
||||
),
|
||||
child: ScopedModelDescendant<AppStateModel>(
|
||||
builder: (BuildContext context, Widget? child, AppStateModel model) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
ListView(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: _leftColumnWidth,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.keyboard_arrow_down),
|
||||
onPressed: () => ExpandingBottomSheet.of(context)!.close(),
|
||||
),
|
||||
Text(
|
||||
'CART',
|
||||
style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(width: 16.0),
|
||||
Text('${model.totalCartQuantity} ITEMS'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
Column(
|
||||
children: _createShoppingCartRows(model),
|
||||
),
|
||||
ShoppingCartSummary(model: model),
|
||||
const SizedBox(height: 100.0),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
bottom: 16.0,
|
||||
left: 16.0,
|
||||
right: 16.0,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: kShrinePink100,
|
||||
shape: const BeveledRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(7.0)),
|
||||
),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12.0),
|
||||
child: Text('CLEAR CART'),
|
||||
),
|
||||
onPressed: () {
|
||||
model.clearCart();
|
||||
ExpandingBottomSheet.of(context)!.close();
|
||||
},
|
||||
Text(
|
||||
'CART',
|
||||
style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(width: 16.0),
|
||||
Text('${model.totalCartQuantity} ITEMS'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
Column(
|
||||
children: _createShoppingCartRows(model),
|
||||
),
|
||||
ShoppingCartSummary(model: model),
|
||||
const SizedBox(height: 100.0),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
bottom: 16.0,
|
||||
left: 16.0,
|
||||
right: 16.0,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: kShrinePink100,
|
||||
shape: const BeveledRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(7.0)),
|
||||
),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12.0),
|
||||
child: Text('CLEAR CART'),
|
||||
),
|
||||
onPressed: () {
|
||||
model.clearCart();
|
||||
ExpandingBottomSheet.of(context)!.close();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -235,12 +235,10 @@ class CupertinoActionSheet extends StatelessWidget {
|
|||
height: 0.0,
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
child: _CupertinoAlertActionSection(
|
||||
children: actions!,
|
||||
scrollController: actionScrollController,
|
||||
hasCancelButton: cancelButton != null,
|
||||
),
|
||||
return _CupertinoAlertActionSection(
|
||||
children: actions!,
|
||||
scrollController: actionScrollController,
|
||||
hasCancelButton: cancelButton != null,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -657,11 +657,9 @@ class _TileIcon extends StatelessWidget {
|
|||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
heightFactor: 1.0,
|
||||
child: Container(
|
||||
child: IconTheme(
|
||||
data: iconThemeData,
|
||||
child: selected ? item.activeIcon : item.icon,
|
||||
),
|
||||
child: IconTheme(
|
||||
data: iconThemeData,
|
||||
child: selected ? item.activeIcon : item.icon,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1137,19 +1137,17 @@ void main() {
|
|||
home: Builder(builder: (BuildContext context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaleFactor: 99),
|
||||
child: CupertinoPageScaffold(
|
||||
child: const CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
CupertinoSliverNavigationBar(
|
||||
leading: Text('leading'),
|
||||
middle: Text('middle'),
|
||||
largeTitle: Text('Large Title'),
|
||||
trailing: Text('trailing'),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
child: const Text('content'),
|
||||
),
|
||||
child: Text('content'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1185,17 +1183,15 @@ void main() {
|
|||
builder: (BuildContext context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaleFactor: 99),
|
||||
child: Container(
|
||||
child: const CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
CupertinoSliverNavigationBar(
|
||||
automaticallyImplyLeading: true,
|
||||
automaticallyImplyTitle: true,
|
||||
previousPageTitle: 'previous title',
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
CupertinoSliverNavigationBar(
|
||||
automaticallyImplyLeading: true,
|
||||
automaticallyImplyTitle: true,
|
||||
previousPageTitle: 'previous title',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -3732,12 +3732,11 @@ void main() {
|
|||
),
|
||||
Expanded(
|
||||
child: Navigator(
|
||||
onGenerateRoute: (_) =>
|
||||
CupertinoPageRoute<void>(builder: (_) => Container(
|
||||
child: CupertinoTextField(
|
||||
controller: controller,
|
||||
),
|
||||
)),
|
||||
onGenerateRoute: (_) => CupertinoPageRoute<void>(
|
||||
builder: (_) => CupertinoTextField(
|
||||
controller: controller,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -487,9 +487,7 @@ void main() {
|
|||
|
||||
|
||||
showModalBottomSheet<void>(context: scaffoldKey.currentContext!, builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: const Text('BottomSheet'),
|
||||
);
|
||||
return const Text('BottomSheet');
|
||||
});
|
||||
|
||||
await tester.pump(); // bottom sheet show animation starts
|
||||
|
@ -548,9 +546,7 @@ void main() {
|
|||
shape: shape,
|
||||
clipBehavior: clipBehavior,
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: const Text('BottomSheet'),
|
||||
);
|
||||
return const Text('BottomSheet');
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -587,9 +583,7 @@ void main() {
|
|||
builder: (_, ScrollController controller) {
|
||||
return SingleChildScrollView(
|
||||
controller: controller,
|
||||
child: Container(
|
||||
child: const Text('BottomSheet'),
|
||||
),
|
||||
child: const Text('BottomSheet'),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -713,9 +707,7 @@ void main() {
|
|||
routeSettings: routeSettings,
|
||||
builder: (BuildContext context) {
|
||||
retrievedRouteSettings = ModalRoute.of(context)!.settings;
|
||||
return Container(
|
||||
child: const Text('BottomSheet'),
|
||||
);
|
||||
return const Text('BottomSheet');
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -743,9 +735,7 @@ void main() {
|
|||
reverseDuration: const Duration(seconds: 2),
|
||||
),
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: const Text('BottomSheet'),
|
||||
);
|
||||
return const Text('BottomSheet');
|
||||
},
|
||||
);
|
||||
},
|
||||
|
|
|
@ -245,9 +245,7 @@ void main() {
|
|||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: const Text('This is a modal bottom sheet.'),
|
||||
);
|
||||
return const Text('This is a modal bottom sheet.');
|
||||
},
|
||||
);
|
||||
},
|
||||
|
@ -299,10 +297,8 @@ Widget bottomSheetWithElevations(BottomSheetThemeData bottomSheetTheme) {
|
|||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext _) {
|
||||
return Container(
|
||||
child: const Text(
|
||||
'This is a modal bottom sheet.',
|
||||
),
|
||||
return const Text(
|
||||
'This is a modal bottom sheet.',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -314,10 +310,8 @@ Widget bottomSheetWithElevations(BottomSheetThemeData bottomSheetTheme) {
|
|||
showBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext _) {
|
||||
return Container(
|
||||
child: const Text(
|
||||
'This is a persistent bottom sheet.',
|
||||
),
|
||||
return const Text(
|
||||
'This is a persistent bottom sheet.',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -168,17 +168,13 @@ void main() {
|
|||
|
||||
testWidgets('Open/close drawers by flinging', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
drawer: Drawer(
|
||||
child: Container(
|
||||
child: const Text('start drawer'),
|
||||
),
|
||||
child: Text('start drawer'),
|
||||
),
|
||||
endDrawer: Drawer(
|
||||
child: Container(
|
||||
child: const Text('end drawer'),
|
||||
),
|
||||
child: Text('end drawer'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -103,9 +103,7 @@ class ExpansionPanelListSemanticsTestState extends State<ExpansionPanelListSeman
|
|||
),
|
||||
);
|
||||
},
|
||||
body: Container(
|
||||
child: const Placeholder(),
|
||||
),
|
||||
body: const Placeholder(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -60,13 +60,11 @@ void main() {
|
|||
flexibleSpace: RepaintBoundary(
|
||||
child: FlexibleSpaceBar(
|
||||
stretchModes: const <StretchMode>[StretchMode.blurBackground],
|
||||
background: Container(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(child: Container(color: Colors.red)),
|
||||
Expanded(child:Container(color: Colors.blue)),
|
||||
],
|
||||
)
|
||||
background: Row(
|
||||
children: <Widget>[
|
||||
Expanded(child: Container(color: Colors.red)),
|
||||
Expanded(child:Container(color: Colors.blue)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -287,7 +287,7 @@ void main() {
|
|||
onPressed: () { Navigator.of(context).pushNamed('/b'); },
|
||||
),
|
||||
),
|
||||
'/b': (BuildContext context) => Container(child: const Text('HELLO')),
|
||||
'/b': (BuildContext context) => const Text('HELLO'),
|
||||
};
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
|
|
@ -1151,26 +1151,24 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: PopupMenuButton<String>(
|
||||
onSelected: (String result) {
|
||||
selectedValue = result;
|
||||
},
|
||||
child: const Text('Menu Button'),
|
||||
initialValue: '1',
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
child: Text('1'),
|
||||
value: '1',
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
const PopupMenuItem<String>(
|
||||
child: Text('2'),
|
||||
value: '2',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Center(
|
||||
child: PopupMenuButton<String>(
|
||||
onSelected: (String result) {
|
||||
selectedValue = result;
|
||||
},
|
||||
child: const Text('Menu Button'),
|
||||
initialValue: '1',
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
child: Text('1'),
|
||||
value: '1',
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
const PopupMenuItem<String>(
|
||||
child: Text('2'),
|
||||
value: '2',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1831,9 +1831,7 @@ void main() {
|
|||
body: Center(
|
||||
child: Container(),
|
||||
),
|
||||
bottomSheet: Container(
|
||||
child: const Text('Bottom sheet'),
|
||||
),
|
||||
bottomSheet: const Text('Bottom sheet'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -2397,14 +2397,12 @@ void main() {
|
|||
required List<String> tabs,
|
||||
}) {
|
||||
return boilerplate(
|
||||
child: Container(
|
||||
child: TabBar(
|
||||
controller: controller,
|
||||
tabs: tabs.map<Widget>((String tab) => Tab(text: tab)).toList(),
|
||||
onTap: (int index) {
|
||||
tabIndex = index;
|
||||
},
|
||||
),
|
||||
child: TabBar(
|
||||
controller: controller,
|
||||
tabs: tabs.map<Widget>((String tab) => Tab(text: tab)).toList(),
|
||||
onTap: (int index) {
|
||||
tabIndex = index;
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3568,11 +3568,9 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
overlay(
|
||||
child: Container(
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
maxLines: 6,
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
maxLines: 6,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -1592,17 +1592,13 @@ void main() {
|
|||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: Container(
|
||||
child: ListView(
|
||||
scrollDirection: a1,
|
||||
children: List<Widget>.generate(10, (int y) {
|
||||
return Container(
|
||||
child: ListView(
|
||||
scrollDirection: a2,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
child: ListView(
|
||||
scrollDirection: a1,
|
||||
children: List<Widget>.generate(10, (int y) {
|
||||
return ListView(
|
||||
scrollDirection: a2,
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -379,11 +379,9 @@ void main() {
|
|||
actions: <Type, Action<Intent>>{
|
||||
TestIntent: testAction,
|
||||
},
|
||||
child: Container(
|
||||
child: Actions(
|
||||
actions: const <Type, Action<Intent>>{},
|
||||
child: Container(key: containerKey),
|
||||
),
|
||||
child: Actions(
|
||||
actions: const <Type, Action<Intent>>{},
|
||||
child: Container(key: containerKey),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -175,7 +175,7 @@ void tests({ required bool impliedMode }) {
|
|||
childAspectRatio: 400.0 / 24.6, // about 50 widgets visible
|
||||
cacheExtent: 0.0,
|
||||
children: generateList(
|
||||
Container(child: const Placeholder()),
|
||||
const Placeholder(),
|
||||
impliedMode: impliedMode,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -220,21 +220,19 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: <Widget>[
|
||||
Text('big text',
|
||||
key: key1,
|
||||
style: const TextStyle(fontSize: fontSize1),
|
||||
),
|
||||
Text('one\ntwo\nthree\nfour\nfive\nsix\nseven',
|
||||
key: key2,
|
||||
style: const TextStyle(fontSize: fontSize2),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: <Widget>[
|
||||
Text('big text',
|
||||
key: key1,
|
||||
style: const TextStyle(fontSize: fontSize1),
|
||||
),
|
||||
Text('one\ntwo\nthree\nfour\nfive\nsix\nseven',
|
||||
key: key2,
|
||||
style: const TextStyle(fontSize: fontSize2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -277,22 +275,20 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: <Widget>[
|
||||
Text('big text',
|
||||
key: key1,
|
||||
style: const TextStyle(fontSize: fontSize1),
|
||||
),
|
||||
Text('one\ntwo\nthree\nfour\nfive\nsix\nseven',
|
||||
key: key2,
|
||||
style: const TextStyle(fontSize: fontSize2),
|
||||
),
|
||||
const FlutterLogo(size: 250),
|
||||
],
|
||||
),
|
||||
body: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: <Widget>[
|
||||
Text('big text',
|
||||
key: key1,
|
||||
style: const TextStyle(fontSize: fontSize1),
|
||||
),
|
||||
Text('one\ntwo\nthree\nfour\nfive\nsix\nseven',
|
||||
key: key2,
|
||||
style: const TextStyle(fontSize: fontSize2),
|
||||
),
|
||||
const FlutterLogo(size: 250),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -408,14 +408,12 @@ void main() {
|
|||
onTap: () {
|
||||
events.add('tap');
|
||||
},
|
||||
child: Container(
|
||||
child: const Text('Button'),
|
||||
),
|
||||
child: const Text('Button'),
|
||||
),
|
||||
DragTarget<int>(
|
||||
builder: (BuildContext context, List<int?> data, List<dynamic> rejects) {
|
||||
return IgnorePointer(
|
||||
child: Container(child: const Text('Target')),
|
||||
return const IgnorePointer(
|
||||
child: Text('Target'),
|
||||
);
|
||||
},
|
||||
onAccept: (int? data) {
|
||||
|
@ -498,7 +496,7 @@ void main() {
|
|||
onTap: () {
|
||||
events.add('tap');
|
||||
},
|
||||
child: Container(child: const Text('Button')),
|
||||
child: const Text('Button'),
|
||||
),
|
||||
feedback: const Text('Dragging'),
|
||||
),
|
||||
|
|
|
@ -273,11 +273,9 @@ void main() {
|
|||
],
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
child: TextButton(
|
||||
child: const Text('button'),
|
||||
onPressed: () { buttonPressed = true; },
|
||||
),
|
||||
body: TextButton(
|
||||
child: const Text('button'),
|
||||
onPressed: () { buttonPressed = true; },
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
@ -4681,19 +4681,17 @@ void main() {
|
|||
await tester.pumpWidget(MaterialApp(
|
||||
home: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
child: EditableText(
|
||||
showSelectionHandles: true,
|
||||
controller: controller,
|
||||
focusNode: FocusNode(),
|
||||
style: Typography.material2018(platform: TargetPlatform.iOS).black.subtitle1!,
|
||||
cursorColor: Colors.blue,
|
||||
backgroundCursorColor: Colors.grey,
|
||||
selectionControls: cupertinoTextSelectionControls,
|
||||
keyboardType: TextInputType.text,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
child: EditableText(
|
||||
showSelectionHandles: true,
|
||||
controller: controller,
|
||||
focusNode: FocusNode(),
|
||||
style: Typography.material2018(platform: TargetPlatform.iOS).black.subtitle1!,
|
||||
cursorColor: Colors.blue,
|
||||
backgroundCursorColor: Colors.grey,
|
||||
selectionControls: cupertinoTextSelectionControls,
|
||||
keyboardType: TextInputType.text,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1141,20 +1141,16 @@ void main() {
|
|||
children: <Widget>[
|
||||
Focus(
|
||||
key: key2,
|
||||
child: Container(
|
||||
child: Focus(
|
||||
key: key3,
|
||||
child: Container(),
|
||||
),
|
||||
child: Focus(
|
||||
key: key3,
|
||||
child: Container(),
|
||||
),
|
||||
),
|
||||
Focus(
|
||||
key: key4,
|
||||
child: Container(
|
||||
child: Focus(
|
||||
key: key5,
|
||||
child: Container(),
|
||||
),
|
||||
child: Focus(
|
||||
key: key5,
|
||||
child: Container(),
|
||||
),
|
||||
),
|
||||
Focus(
|
||||
|
|
|
@ -904,7 +904,7 @@ void main() {
|
|||
children: <Widget>[
|
||||
const SwapKeyWidget(childKey: ValueKey<int>(0)),
|
||||
Container(key: const ValueKey<int>(1)),
|
||||
Container(child: SizedBox(key: key)),
|
||||
Container(color: Colors.green, child: SizedBox(key: key)),
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(stack);
|
||||
|
@ -1160,7 +1160,7 @@ void main() {
|
|||
children: <Widget>[
|
||||
Container(),
|
||||
Container(key: key1 = GlobalKey()),
|
||||
Container(child: Container()),
|
||||
Container(),
|
||||
Container(key: key2 = GlobalKey()),
|
||||
Container(),
|
||||
],
|
||||
|
@ -1179,7 +1179,7 @@ void main() {
|
|||
children: <Widget>[
|
||||
Container(),
|
||||
Container(key: GlobalKey()),
|
||||
Container(child: Container()),
|
||||
Container(color: Colors.green, child: Container()),
|
||||
Container(key: GlobalKey()),
|
||||
Container(),
|
||||
],
|
||||
|
@ -1197,10 +1197,11 @@ void main() {
|
|||
'├Container-[GlobalKey#00000]\n'
|
||||
'│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n'
|
||||
'│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n'
|
||||
'├Container\n'
|
||||
'│└Container\n'
|
||||
'│ └LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n'
|
||||
'│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n'
|
||||
'├Container(bg: MaterialColor(primary value: Color(0xff4caf50)))\n'
|
||||
'│└ColoredBox(color: MaterialColor(primary value: Color(0xff4caf50)), renderObject: _RenderColoredBox#00000 relayoutBoundary=up1)\n'
|
||||
'│ └Container\n'
|
||||
'│ └LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up2)\n'
|
||||
'│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up3)\n'
|
||||
'├Container-[GlobalKey#00000]\n'
|
||||
'│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n'
|
||||
'│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n'
|
||||
|
@ -1462,7 +1463,7 @@ void main() {
|
|||
|
||||
testWidgets('A widget whose element has an invalid visitChildren implementation triggers a useful error message', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(Container(child: _WidgetWithNoVisitChildren(_StatefulLeaf(key: key))));
|
||||
await tester.pumpWidget(_WidgetWithNoVisitChildren(_StatefulLeaf(key: key)));
|
||||
(key.currentState! as _StatefulLeafState).markNeedsBuild();
|
||||
await tester.pumpWidget(Container());
|
||||
final dynamic exception = tester.takeException();
|
||||
|
|
|
@ -858,9 +858,7 @@ void main() {
|
|||
textDirection: TextDirection.ltr,
|
||||
child: RawGestureDetector(
|
||||
key: key,
|
||||
child: Container(
|
||||
child: const Text('Text'),
|
||||
),
|
||||
child: const Text('Text'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -12,9 +12,9 @@ void main() {
|
|||
testWidgets('GlobalKey children of one node', (WidgetTester tester) async {
|
||||
// This is actually a test of the regular duplicate key logic, which
|
||||
// happens before the duplicate GlobalKey logic.
|
||||
await tester.pumpWidget(Stack(children: <Widget>[
|
||||
Container(key: const GlobalObjectKey(0)),
|
||||
Container(key: const GlobalObjectKey(0)),
|
||||
await tester.pumpWidget(Stack(children: const <Widget>[
|
||||
DummyWidget(key: GlobalObjectKey(0)),
|
||||
DummyWidget(key: GlobalObjectKey(0)),
|
||||
]));
|
||||
final dynamic error = tester.takeException();
|
||||
expect(error, isFlutterError);
|
||||
|
@ -23,56 +23,61 @@ void main() {
|
|||
expect(error.toString(), contains('[GlobalObjectKey ${describeIdentity(0)}]'));
|
||||
});
|
||||
|
||||
testWidgets('GlobalKey children of two nodes', (WidgetTester tester) async {
|
||||
testWidgets('GlobalKey children of two nodes - A', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(child: Container(key: const GlobalObjectKey(0))),
|
||||
Container(child: Container(key: const GlobalObjectKey(0))),
|
||||
children: const <Widget>[
|
||||
DummyWidget(child: DummyWidget(key: GlobalObjectKey(0))),
|
||||
DummyWidget(
|
||||
child: DummyWidget(key: GlobalObjectKey(0),
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
final dynamic error = tester.takeException();
|
||||
expect(error, isFlutterError);
|
||||
expect(error.toString(), startsWith('Multiple widgets used the same GlobalKey.\n'));
|
||||
expect(error.toString(), contains('different widgets that both had the following description'));
|
||||
expect(error.toString(), contains('Container'));
|
||||
expect(error.toString(), contains('DummyWidget'));
|
||||
expect(error.toString(), contains('[GlobalObjectKey ${describeIdentity(0)}]'));
|
||||
expect(error.toString(), endsWith('\nA GlobalKey can only be specified on one widget at a time in the widget tree.'));
|
||||
});
|
||||
|
||||
testWidgets('GlobalKey children of two different nodes', (WidgetTester tester) async {
|
||||
testWidgets('GlobalKey children of two different nodes - B', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(child: Container(key: const GlobalObjectKey(0))),
|
||||
Container(key: const Key('x'), child: Container(key: const GlobalObjectKey(0))),
|
||||
children: const <Widget>[
|
||||
DummyWidget(child: DummyWidget(key: GlobalObjectKey(0))),
|
||||
DummyWidget(key: Key('x'), child: DummyWidget(key: GlobalObjectKey(0))),
|
||||
],
|
||||
));
|
||||
final dynamic error = tester.takeException();
|
||||
expect(error, isFlutterError);
|
||||
expect(error.toString(), startsWith('Multiple widgets used the same GlobalKey.\n'));
|
||||
expect(error.toString(), isNot(contains('different widgets that both had the following description')));
|
||||
expect(error.toString(), contains('Container'));
|
||||
expect(error.toString(), contains("Container-[<'x'>]"));
|
||||
expect(error.toString(), contains('DummyWidget'));
|
||||
expect(error.toString(), contains("DummyWidget-[<'x'>]"));
|
||||
expect(error.toString(), contains('[GlobalObjectKey ${describeIdentity(0)}]'));
|
||||
expect(error.toString(), endsWith('\nA GlobalKey can only be specified on one widget at a time in the widget tree.'));
|
||||
});
|
||||
|
||||
testWidgets('GlobalKey children of two nodes', (WidgetTester tester) async {
|
||||
testWidgets('GlobalKey children of two nodes - C', (WidgetTester tester) async {
|
||||
late StateSetter nestedSetState;
|
||||
bool flag = false;
|
||||
await tester.pumpWidget(Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(child: Container(key: const GlobalObjectKey(0))),
|
||||
Container(child: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
nestedSetState = setState;
|
||||
if (flag)
|
||||
return Container(key: const GlobalObjectKey(0));
|
||||
return Container();
|
||||
},
|
||||
)),
|
||||
const DummyWidget(child: DummyWidget(key: GlobalObjectKey(0))),
|
||||
DummyWidget(
|
||||
child: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
nestedSetState = setState;
|
||||
if (flag)
|
||||
return const DummyWidget(key: GlobalObjectKey(0));
|
||||
return const DummyWidget();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
nestedSetState(() { flag = true; });
|
||||
|
@ -84,8 +89,23 @@ void main() {
|
|||
// We should probably also verify the three other combinations that can be generated...
|
||||
expect(error.toString().split('\n').join(' '), contains('This was determined by noticing that after the widget with the above global key was moved out of its previous parent, that previous parent never updated during this frame, meaning that it either did not update at all or updated before the widget was moved, in either case implying that it still thinks that it should have a child with that global key.'));
|
||||
expect(error.toString(), contains('[GlobalObjectKey ${describeIdentity(0)}]'));
|
||||
expect(error.toString(), contains('Container'));
|
||||
expect(error.toString(), contains('DummyWidget'));
|
||||
expect(error.toString(), endsWith('\nA GlobalKey can only be specified on one widget at a time in the widget tree.'));
|
||||
expect(error, isFlutterError);
|
||||
});
|
||||
}
|
||||
|
||||
class DummyWidget extends StatelessWidget {
|
||||
const DummyWidget({ Key? key, this.child }) : super(key: key);
|
||||
|
||||
final Widget? child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return child ?? LimitedBox(
|
||||
maxWidth: 0.0,
|
||||
maxHeight: 0.0,
|
||||
child: ConstrainedBox(constraints: const BoxConstraints.expand()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,9 +160,7 @@ void main() {
|
|||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
log.add(i);
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
@ -254,9 +252,7 @@ void main() {
|
|||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
log.add(i);
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
@ -292,9 +288,7 @@ void main() {
|
|||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
log.add(i);
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
@ -353,9 +347,7 @@ void main() {
|
|||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
log.add(i);
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
@ -391,9 +383,7 @@ void main() {
|
|||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
log.add(i);
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
@ -454,9 +444,7 @@ void main() {
|
|||
child: GridView.count(
|
||||
crossAxisCount: 4,
|
||||
children: List<Widget>.generate(20, (int i) {
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
@ -477,9 +465,7 @@ void main() {
|
|||
crossAxisCount: 4,
|
||||
shrinkWrap: true,
|
||||
children: List<Widget>.generate(20, (int i) {
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
@ -501,9 +487,7 @@ void main() {
|
|||
shrinkWrap: true,
|
||||
itemCount: 20,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
child: Text('$index'),
|
||||
);
|
||||
return Text('$index');
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -523,9 +507,7 @@ void main() {
|
|||
),
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
child: Text('$index'),
|
||||
);
|
||||
return Text('$index');
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -743,9 +725,7 @@ void main() {
|
|||
children: List<Widget>.generate(20, (int i) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
@ -771,9 +751,7 @@ void main() {
|
|||
children: List<Widget>.generate(20, (int i) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
|
|
@ -944,9 +944,7 @@ Future<void> main() async {
|
|||
children: <Widget> [
|
||||
const SizedBox(height: 200.0),
|
||||
// This container will appear at Y=200
|
||||
Container(
|
||||
child: const Hero(tag: 'H', child: SizedBox(key: homeHeroKey, height: 100.0, width: 100.0)),
|
||||
),
|
||||
const Hero(tag: 'H', child: SizedBox(key: homeHeroKey, height: 100.0, width: 100.0)),
|
||||
TextButton(
|
||||
child: const Text('PUSH'),
|
||||
onPressed: () { Navigator.push(context, route); },
|
||||
|
@ -1023,9 +1021,7 @@ Future<void> main() async {
|
|||
children: <Widget> [
|
||||
const SizedBox(height: 200.0),
|
||||
// This container will appear at Y=200
|
||||
Container(
|
||||
child: const Hero(tag: 'H', child: SizedBox(key: homeHeroKey, height: 100.0, width: 100.0)),
|
||||
),
|
||||
const Hero(tag: 'H', child: SizedBox(key: homeHeroKey, height: 100.0, width: 100.0)),
|
||||
TextButton(
|
||||
child: const Text('PUSH'),
|
||||
onPressed: () { Navigator.push(context, route); },
|
||||
|
@ -1077,19 +1073,17 @@ Future<void> main() async {
|
|||
builder: (BuildContext context) {
|
||||
return Material(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
children: const <Widget>[
|
||||
// This container will appear at Y=0
|
||||
Container(
|
||||
child: const Hero(
|
||||
tag: 'BC',
|
||||
child: SizedBox(
|
||||
key: heroBCKey,
|
||||
height: 150.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
Hero(
|
||||
tag: 'BC',
|
||||
child: SizedBox(
|
||||
key: heroBCKey,
|
||||
height: 150.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 800.0),
|
||||
SizedBox(height: 800.0),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -1104,27 +1098,23 @@ Future<void> main() async {
|
|||
children: <Widget>[
|
||||
const SizedBox(height: 100.0),
|
||||
// This container will appear at Y=100
|
||||
Container(
|
||||
child: const Hero(
|
||||
tag: 'AB',
|
||||
child: SizedBox(
|
||||
key: heroABKey,
|
||||
height: 200.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
const Hero(
|
||||
tag: 'AB',
|
||||
child: SizedBox(
|
||||
key: heroABKey,
|
||||
height: 200.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('PUSH C'),
|
||||
onPressed: () { Navigator.push(context, routeC); },
|
||||
),
|
||||
Container(
|
||||
child: const Hero(
|
||||
tag: 'BC',
|
||||
child: SizedBox(
|
||||
height: 150.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
const Hero(
|
||||
tag: 'BC',
|
||||
child: SizedBox(
|
||||
height: 150.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 800.0),
|
||||
|
@ -1144,14 +1134,12 @@ Future<void> main() async {
|
|||
children: <Widget> [
|
||||
const SizedBox(height: 200.0),
|
||||
// This container will appear at Y=200
|
||||
Container(
|
||||
child: const Hero(
|
||||
tag: 'AB',
|
||||
child: SizedBox(
|
||||
height: 100.0,
|
||||
width: 100.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
const Hero(
|
||||
tag: 'AB',
|
||||
child: SizedBox(
|
||||
height: 100.0,
|
||||
width: 100.0,
|
||||
child: Text('Hero'),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
|
@ -2107,15 +2095,13 @@ Future<void> main() async {
|
|||
|
||||
testWidgets('Hero within a Hero subtree, throws', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
child: Container(
|
||||
child: const Hero(
|
||||
tag: 'a',
|
||||
child: Hero(
|
||||
tag: 'b',
|
||||
child: Text('Child of a Hero'),
|
||||
),
|
||||
child: Hero(
|
||||
tag: 'a',
|
||||
child: Hero(
|
||||
tag: 'b',
|
||||
child: Text('Child of a Hero'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -2426,11 +2412,9 @@ Future<void> main() async {
|
|||
child: Hero(
|
||||
tag: 'hero',
|
||||
transitionOnUserGestures: true,
|
||||
child: Container(
|
||||
child: Image(
|
||||
image: imageProvider,
|
||||
key: imageKey2,
|
||||
),
|
||||
child: Image(
|
||||
image: imageProvider,
|
||||
key: imageKey2,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -152,12 +152,10 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: HtmlElementView(viewType: 'webview', key: key),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: HtmlElementView(viewType: 'webview', key: key),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -118,48 +118,32 @@ void main() {
|
|||
final List<String> log = <String>[];
|
||||
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
child: ValueInherited(
|
||||
value: 1,
|
||||
child: Container(
|
||||
child: FlipWidget(
|
||||
left: Container(
|
||||
child: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
child: ValueInherited(
|
||||
value: 3,
|
||||
child: Container(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('a: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
right: Container(
|
||||
child: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
child: Container(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('b: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
ValueInherited(
|
||||
value: 1,
|
||||
child: FlipWidget(
|
||||
left: ValueInherited(
|
||||
value: 2,
|
||||
child: ValueInherited(
|
||||
value: 3,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('a: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
right: ValueInherited(
|
||||
value: 2,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('b: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -192,47 +176,35 @@ void main() {
|
|||
final Key key = GlobalKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
child: ValueInherited(
|
||||
value: 1,
|
||||
child: Container(
|
||||
child: FlipWidget(
|
||||
left: Container(
|
||||
child: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
child: ValueInherited(
|
||||
value: 3,
|
||||
child: Container(
|
||||
key: key,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('a: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
ValueInherited(
|
||||
value: 1,
|
||||
child: FlipWidget(
|
||||
left: ValueInherited(
|
||||
value: 2,
|
||||
child: ValueInherited(
|
||||
value: 3,
|
||||
child: Container(
|
||||
key: key,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('a: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
right: Container(
|
||||
child: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
child: Container(
|
||||
key: key,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('b: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
right: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
key: key,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
|
||||
log.add('b: ${v.value}');
|
||||
return const Text('', textDirection: TextDirection.ltr);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -275,38 +247,26 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
child: ValueInherited(
|
||||
value: 1,
|
||||
child: Container(
|
||||
child: FlipWidget(
|
||||
left: Container(
|
||||
child: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
child: ValueInherited(
|
||||
value: 3,
|
||||
child: Container(
|
||||
key: key,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
right: Container(
|
||||
child: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
child: Container(
|
||||
key: key,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
ValueInherited(
|
||||
value: 1,
|
||||
child: FlipWidget(
|
||||
left: ValueInherited(
|
||||
value: 2,
|
||||
child: ValueInherited(
|
||||
value: 3,
|
||||
child: Container(
|
||||
key: key,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
right: ValueInherited(
|
||||
value: 2,
|
||||
child: Container(
|
||||
key: key,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -29,7 +29,16 @@ class TestWidgetState extends State<TestWidget> {
|
|||
|
||||
void main() {
|
||||
testWidgets('initState() is called when we are in the tree', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Container(child: const TestWidget()));
|
||||
expect(ancestors, equals(<String>['Container', 'RenderObjectToWidgetAdapter<RenderBox>']));
|
||||
await tester.pumpWidget(const Parent(child: TestWidget()));
|
||||
expect(ancestors, equals(<String>['Parent', 'RenderObjectToWidgetAdapter<RenderBox>']));
|
||||
});
|
||||
}
|
||||
|
||||
class Parent extends StatelessWidget {
|
||||
const Parent({ Key? key, required this.child }) : super(key: key);
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => child;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ void main() {
|
|||
addSemanticIndexes: false,
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 400.0 / 24.6, // about 50 widgets visible
|
||||
children: generateList(Container(child: const Placeholder())),
|
||||
children: generateList(const Placeholder()),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -65,9 +65,7 @@ class _StatefulListViewState extends State<_StatefulListView> {
|
|||
children: List<Widget>.generate(200, (int i) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
child: Alive(widget.aliveCallback(i), i),
|
||||
);
|
||||
return Alive(widget.aliveCallback(i), i);
|
||||
},
|
||||
);
|
||||
}),
|
||||
|
@ -97,6 +95,7 @@ void main() {
|
|||
itemExtent: 200.0,
|
||||
children: List<Widget>.generate(20, (int i) {
|
||||
return Container(
|
||||
color: Colors.green,
|
||||
child: Text('$i'),
|
||||
);
|
||||
}),
|
||||
|
@ -147,9 +146,7 @@ void main() {
|
|||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
log.add(i);
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
},
|
||||
);
|
||||
}),
|
||||
|
@ -239,9 +236,7 @@ void main() {
|
|||
child: ListView(
|
||||
itemExtent: 100.0,
|
||||
children: List<Widget>.generate(2, (int i) {
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
@ -260,9 +255,7 @@ void main() {
|
|||
child: ListView(
|
||||
itemExtent: 100.0,
|
||||
children: List<Widget>.generate(5, (int i) {
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
@ -306,9 +299,7 @@ void main() {
|
|||
itemExtent: 100.0,
|
||||
shrinkWrap: true,
|
||||
children: List<Widget>.generate(20, (int i) {
|
||||
return Container(
|
||||
child: Text('$i'),
|
||||
);
|
||||
return Text('$i');
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
@ -324,9 +315,7 @@ void main() {
|
|||
List<Widget>.generate(
|
||||
20,
|
||||
(int i) {
|
||||
return Container(
|
||||
child: Text('$i', textDirection: TextDirection.ltr),
|
||||
);
|
||||
return Text('$i', textDirection: TextDirection.ltr);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
@ -14,9 +14,7 @@ Widget buildFrame() {
|
|||
itemExtent: 290.0,
|
||||
scrollDirection: Axis.vertical,
|
||||
children: items.map<Widget>((int item) {
|
||||
return Container(
|
||||
child: Text('$item'),
|
||||
);
|
||||
return Text('$item');
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
|
@ -75,9 +73,7 @@ void main() {
|
|||
padding: const EdgeInsets.only(top: 250.0),
|
||||
scrollDirection: Axis.vertical,
|
||||
children: items.map<Widget>((int item) {
|
||||
return Container(
|
||||
child: Text('$item'),
|
||||
);
|
||||
return Text('$item');
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1282,13 +1282,11 @@ void main() {
|
|||
controller: ScrollController(initialScrollOffset: 300.0),
|
||||
itemExtent: 100.0,
|
||||
children: outerChildren = List<Widget>.generate(10, (int i) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: innerChildren[i] = SizedBox(
|
||||
height: 50.0,
|
||||
width: 50.0,
|
||||
child: Text('Item $i'),
|
||||
),
|
||||
return Center(
|
||||
child: innerChildren[i] = SizedBox(
|
||||
height: 50.0,
|
||||
width: 50.0,
|
||||
child: Text('Item $i'),
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
@ -1354,13 +1352,11 @@ void main() {
|
|||
itemExtent: 100.0,
|
||||
children:
|
||||
outerChildren = List<Widget>.generate(10, (int i) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: innerChildren[i] = SizedBox(
|
||||
height: 50.0,
|
||||
width: 50.0,
|
||||
child: Text('Item $i'),
|
||||
),
|
||||
return Center(
|
||||
child: innerChildren[i] = SizedBox(
|
||||
height: 50.0,
|
||||
width: 50.0,
|
||||
child: Text('Item $i'),
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
|
|
@ -426,9 +426,7 @@ class FirstWidget extends StatelessWidget {
|
|||
onTap: () {
|
||||
Navigator.pushNamed(context, '/modal');
|
||||
},
|
||||
child: Container(
|
||||
child: const Text('X'),
|
||||
),
|
||||
child: const Text('X'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -852,12 +852,10 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: Container(
|
||||
child: HoverFeedback(
|
||||
key: feedbackKey,
|
||||
onEnter: () { numEntrances += 1; },
|
||||
onExit: () { numExits += 1; },
|
||||
),
|
||||
child: HoverFeedback(
|
||||
key: feedbackKey,
|
||||
onEnter: () { numEntrances += 1; },
|
||||
onExit: () { numExits += 1; },
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -145,12 +145,12 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
const DecoratedBox(decoration: kBoxDecorationA),
|
||||
Container(
|
||||
child: const DecoratedBox(decoration: kBoxDecorationB),
|
||||
children: const <Widget>[
|
||||
DecoratedBox(decoration: kBoxDecorationA),
|
||||
DummyWidget(
|
||||
child: DecoratedBox(decoration: kBoxDecorationB),
|
||||
),
|
||||
const DecoratedBox(decoration: kBoxDecorationC),
|
||||
DecoratedBox(decoration: kBoxDecorationC),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -160,14 +160,14 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
const DecoratedBox(decoration: kBoxDecorationA),
|
||||
Container(
|
||||
child: Container(
|
||||
child: const DecoratedBox(decoration: kBoxDecorationB),
|
||||
children: const <Widget>[
|
||||
DecoratedBox(decoration: kBoxDecorationA),
|
||||
DummyWidget(
|
||||
child: DummyWidget(
|
||||
child: DecoratedBox(decoration: kBoxDecorationB),
|
||||
),
|
||||
),
|
||||
const DecoratedBox(decoration: kBoxDecorationC),
|
||||
DecoratedBox(decoration: kBoxDecorationC),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -177,16 +177,16 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Container(
|
||||
child: const DecoratedBox(decoration: kBoxDecorationB),
|
||||
children: const <Widget>[
|
||||
DummyWidget(
|
||||
child: DummyWidget(
|
||||
child: DecoratedBox(decoration: kBoxDecorationB),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: const DecoratedBox(decoration: kBoxDecorationA),
|
||||
DummyWidget(
|
||||
child: DecoratedBox(decoration: kBoxDecorationA),
|
||||
),
|
||||
const DecoratedBox(decoration: kBoxDecorationC),
|
||||
DecoratedBox(decoration: kBoxDecorationC),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -196,14 +196,14 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: const DecoratedBox(decoration: kBoxDecorationB),
|
||||
children: const <Widget>[
|
||||
DummyWidget(
|
||||
child: DecoratedBox(decoration: kBoxDecorationB),
|
||||
),
|
||||
Container(
|
||||
child: const DecoratedBox(decoration: kBoxDecorationA),
|
||||
DummyWidget(
|
||||
child: DecoratedBox(decoration: kBoxDecorationA),
|
||||
),
|
||||
const DecoratedBox(decoration: kBoxDecorationC),
|
||||
DecoratedBox(decoration: kBoxDecorationC),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -213,14 +213,14 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
key: const Key('b'),
|
||||
child: const DecoratedBox(decoration: kBoxDecorationB),
|
||||
children: const <Widget>[
|
||||
DummyWidget(
|
||||
key: Key('b'),
|
||||
child: DecoratedBox(decoration: kBoxDecorationB),
|
||||
),
|
||||
Container(
|
||||
key: const Key('a'),
|
||||
child: const DecoratedBox(decoration: kBoxDecorationA),
|
||||
DummyWidget(
|
||||
key: Key('a'),
|
||||
child: DecoratedBox(decoration: kBoxDecorationA),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -231,14 +231,14 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Stack(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
key: const Key('a'),
|
||||
child: const DecoratedBox(decoration: kBoxDecorationA),
|
||||
children: const <Widget>[
|
||||
DummyWidget(
|
||||
key: Key('a'),
|
||||
child: DecoratedBox(decoration: kBoxDecorationA),
|
||||
),
|
||||
Container(
|
||||
key: const Key('b'),
|
||||
child: const DecoratedBox(decoration: kBoxDecorationB),
|
||||
DummyWidget(
|
||||
key: Key('b'),
|
||||
child: DecoratedBox(decoration: kBoxDecorationB),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -363,3 +363,12 @@ class FakeRenderObject extends RenderBox {
|
|||
size = constraints.biggest;
|
||||
}
|
||||
}
|
||||
|
||||
class DummyWidget extends StatelessWidget {
|
||||
const DummyWidget({ Key? key, required this.child }) : super(key: key);
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => child;
|
||||
}
|
||||
|
|
|
@ -33,20 +33,18 @@ void main() {
|
|||
MaterialApp(
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/': (BuildContext context) => RepaintBoundary(
|
||||
child: Container(
|
||||
child: RepaintBoundary(
|
||||
child: FlipWidget(
|
||||
left: CustomPaint(
|
||||
painter: TestCustomPainter(
|
||||
log: log,
|
||||
name: 'left',
|
||||
),
|
||||
child: RepaintBoundary(
|
||||
child: FlipWidget(
|
||||
left: CustomPaint(
|
||||
painter: TestCustomPainter(
|
||||
log: log,
|
||||
name: 'left',
|
||||
),
|
||||
right: CustomPaint(
|
||||
painter: TestCustomPainter(
|
||||
log: log,
|
||||
name: 'right',
|
||||
),
|
||||
),
|
||||
right: CustomPaint(
|
||||
painter: TestCustomPainter(
|
||||
log: log,
|
||||
name: 'right',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -84,10 +84,8 @@ class OnTapPage extends StatelessWidget {
|
|||
body: GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
child: Center(
|
||||
child: Text(id, style: Theme.of(context).textTheme.headline3),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(id, style: Theme.of(context).textTheme.headline3),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -2075,11 +2075,9 @@ void main() {
|
|||
body: ListView.builder(
|
||||
itemCount: 50,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text('Item $index'),
|
||||
)
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text('Item $index'),
|
||||
);
|
||||
}
|
||||
),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
@ -179,8 +180,8 @@ void main() {
|
|||
right: 10.0,
|
||||
child: Container(child: kDecoratedBoxB),
|
||||
),
|
||||
Container(
|
||||
child: const Positioned(
|
||||
const DummyWidget(
|
||||
child: Positioned(
|
||||
top: 8.0,
|
||||
child: kDecoratedBoxC,
|
||||
),
|
||||
|
@ -293,7 +294,7 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(
|
||||
child: DummyWidget(
|
||||
child: Row(
|
||||
children: const <Widget>[
|
||||
Positioned(
|
||||
|
@ -319,7 +320,7 @@ void main() {
|
|||
'Typically, Positioned widgets are placed directly inside Stack widgets.\n'
|
||||
'The offending Positioned is currently placed inside a Row widget.\n'
|
||||
'The ownership chain for the RenderObject that received the incompatible parent data was:\n'
|
||||
' DecoratedBox ← Positioned ← Row ← Container ← Directionality ← [root]'
|
||||
' DecoratedBox ← Positioned ← Row ← DummyWidget ← Directionality ← [root]'
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -515,3 +516,12 @@ class RenderAnother extends RenderProxyBox {
|
|||
child.parentData = DummyParentData();
|
||||
}
|
||||
}
|
||||
|
||||
class DummyWidget extends StatelessWidget {
|
||||
const DummyWidget({ Key? key, required this.child }) : super(key: key);
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => child;
|
||||
}
|
||||
|
|
|
@ -230,12 +230,10 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -1337,12 +1335,10 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: UiKitView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: UiKitView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -2348,12 +2344,10 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: createPlatformViewLink(),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: createPlatformViewLink(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
|
@ -59,9 +60,11 @@ void main() {
|
|||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Colors.green,
|
||||
child: StateMarker(key: left),
|
||||
),
|
||||
Container(
|
||||
color: Colors.green,
|
||||
child: StateMarker(
|
||||
key: right,
|
||||
child: grandchild,
|
||||
|
@ -86,12 +89,14 @@ void main() {
|
|||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Colors.green,
|
||||
child: StateMarker(
|
||||
key: right,
|
||||
child: newGrandchild,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Colors.green,
|
||||
child: StateMarker(key: left),
|
||||
),
|
||||
],
|
||||
|
@ -111,6 +116,7 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: Container(
|
||||
color: Colors.green,
|
||||
child: StateMarker(
|
||||
key: left,
|
||||
child: Container(),
|
||||
|
@ -178,6 +184,7 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: Container(
|
||||
color: Colors.green,
|
||||
child: StateMarker(
|
||||
key: left,
|
||||
child: Container(),
|
||||
|
|
|
@ -111,11 +111,17 @@ void main() {
|
|||
);
|
||||
}),
|
||||
Container(
|
||||
color: Colors.green,
|
||||
child: Container(
|
||||
color: Colors.green,
|
||||
child: Container(
|
||||
color: Colors.green,
|
||||
child: Container(
|
||||
color: Colors.green,
|
||||
child: Container(
|
||||
color: Colors.green,
|
||||
child: Container(
|
||||
color: Colors.green,
|
||||
child: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
childSetState = setState;
|
||||
|
|
|
@ -21,10 +21,8 @@ class OnTapPage extends StatelessWidget {
|
|||
body: GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
child: Center(
|
||||
child: Text(id, style: Theme.of(context).textTheme.headline3),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(id, style: Theme.of(context).textTheme.headline3),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -39,13 +39,13 @@ Future<void> performTest(WidgetTester tester, bool maintainState) async {
|
|||
if (settings.name == '/') {
|
||||
return MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Container(child: const ThePositiveNumbers(from: 0)),
|
||||
builder: (_) => const ThePositiveNumbers(from: 0),
|
||||
maintainState: maintainState,
|
||||
);
|
||||
} else if (settings.name == '/second') {
|
||||
return MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Container(child: const ThePositiveNumbers(from: 10000)),
|
||||
builder: (_) => const ThePositiveNumbers(from: 10000),
|
||||
maintainState: maintainState,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -64,12 +64,10 @@ void main() {
|
|||
itemExtent: 290.0,
|
||||
scrollDirection: Axis.vertical,
|
||||
children: items.map<Widget>((int item) {
|
||||
return Container(
|
||||
child: GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
),
|
||||
return GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
@ -107,11 +105,9 @@ void main() {
|
|||
itemExtent: 290.0,
|
||||
padding: const EdgeInsets.fromLTRB(5.0, 20.0, 15.0, 10.0),
|
||||
children: items.map<Widget>((int item) {
|
||||
return Container(
|
||||
child: GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
),
|
||||
return GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
@ -142,11 +138,9 @@ void main() {
|
|||
reverse: true,
|
||||
padding: const EdgeInsets.fromLTRB(5.0, 20.0, 15.0, 10.0),
|
||||
children: items.map<Widget>((int item) {
|
||||
return Container(
|
||||
child: GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
),
|
||||
return GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
@ -176,11 +170,9 @@ void main() {
|
|||
child: ListView(
|
||||
itemExtent: 200.0,
|
||||
children: items.map<Widget>((int item) {
|
||||
return Container(
|
||||
child: GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
),
|
||||
return GestureDetector(
|
||||
onTap: () { tapped.add(item); },
|
||||
child: Text('$item'),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
|
|
@ -269,9 +269,7 @@ void main() {
|
|||
restorationId: 'pager',
|
||||
children: List<Widget>.generate(
|
||||
50,
|
||||
(int index) => Container(
|
||||
child: Text('Tile $index'),
|
||||
),
|
||||
(int index) => Text('Tile $index'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -325,9 +323,7 @@ void main() {
|
|||
itemExtent: 50,
|
||||
children: List<Widget>.generate(
|
||||
50,
|
||||
(int index) => Container(
|
||||
child: Text('Tile $index'),
|
||||
),
|
||||
(int index) => Text('Tile $index'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1157,31 +1157,29 @@ void main() {
|
|||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
controller: outerController,
|
||||
child: Container(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: <Widget>[
|
||||
for (int i = 0; i < 100; i++)
|
||||
Text('SingleChildScrollView $i'),
|
||||
]
|
||||
),
|
||||
SizedBox(
|
||||
height: 3000,
|
||||
width: 400,
|
||||
child: ListView.builder(
|
||||
controller: innerController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: 100,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Text('Nested NeverScrollable ListView $index');
|
||||
},
|
||||
)
|
||||
),
|
||||
]
|
||||
)
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: <Widget>[
|
||||
for (int i = 0; i < 100; i++)
|
||||
Text('SingleChildScrollView $i'),
|
||||
]
|
||||
),
|
||||
SizedBox(
|
||||
height: 3000,
|
||||
width: 400,
|
||||
child: ListView.builder(
|
||||
controller: innerController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: 100,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Text('Nested NeverScrollable ListView $index');
|
||||
},
|
||||
)
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
|
|
|
@ -16,13 +16,11 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
label: 'test1',
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(),
|
||||
selected: true,
|
||||
),
|
||||
child: Semantics(
|
||||
label: 'test1',
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(),
|
||||
selected: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -16,15 +16,11 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Semantics(
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
checked: true
|
||||
),
|
||||
),
|
||||
checked: true
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -47,10 +43,8 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
checked: true,
|
||||
),
|
||||
child: Semantics(
|
||||
checked: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -71,11 +65,9 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
child: Semantics(
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -97,13 +89,11 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
checked: true,
|
||||
child: Semantics(
|
||||
checked: true,
|
||||
child: Semantics(
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -131,13 +121,11 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
Semantics(
|
||||
container: true,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
checked: true,
|
||||
child: Semantics(
|
||||
checked: true,
|
||||
child: Semantics(
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -30,12 +30,10 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
child: Semantics(
|
||||
label: 'test1',
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(),
|
||||
),
|
||||
Semantics(
|
||||
label: 'test1',
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -69,15 +67,13 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
label: 'test1',
|
||||
child: Semantics(
|
||||
label: 'test1',
|
||||
child: Semantics(
|
||||
key: key,
|
||||
container: true,
|
||||
label: 'test2a',
|
||||
child: Container(),
|
||||
),
|
||||
key: key,
|
||||
container: true,
|
||||
label: 'test2a',
|
||||
child: Container(),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
@ -102,18 +98,16 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Container(
|
||||
child: Semantics(
|
||||
label: 'test1',
|
||||
child: Semantics(
|
||||
label: 'test1',
|
||||
container: true,
|
||||
label: 'middle',
|
||||
child: Semantics(
|
||||
key: key,
|
||||
container: true,
|
||||
label: 'middle',
|
||||
child: Semantics(
|
||||
key: key,
|
||||
container: true,
|
||||
label: 'test2b',
|
||||
child: Container(),
|
||||
),
|
||||
label: 'test2b',
|
||||
child: Container(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -295,30 +295,28 @@ class TraversalTester {
|
|||
}) async {
|
||||
assert(children is LinkedHashMap);
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
child: Directionality(
|
||||
textDirection: textDirection,
|
||||
child: Semantics(
|
||||
textDirection: textDirection,
|
||||
child: CustomMultiChildLayout(
|
||||
delegate: TestLayoutDelegate(children),
|
||||
children: children.keys.map<Widget>((String label) {
|
||||
return LayoutId(
|
||||
id: label,
|
||||
child: Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
label: label,
|
||||
child: SizedBox(
|
||||
width: children[label]!.width,
|
||||
height: children[label]!.height,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
Directionality(
|
||||
textDirection: textDirection,
|
||||
child: Semantics(
|
||||
textDirection: textDirection,
|
||||
child: CustomMultiChildLayout(
|
||||
delegate: TestLayoutDelegate(children),
|
||||
children: children.keys.map<Widget>((String label) {
|
||||
return LayoutId(
|
||||
id: label,
|
||||
child: Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
label: label,
|
||||
child: SizedBox(
|
||||
width: children[label]!.width,
|
||||
height: children[label]!.height,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
@ -9,7 +10,7 @@ import 'package:flutter/widgets.dart';
|
|||
void main() {
|
||||
testWidgets('SliverFillViewport control test', (WidgetTester tester) async {
|
||||
final List<Widget> children = List<Widget>.generate(20, (int i) {
|
||||
return Container(child: Text('$i', textDirection: TextDirection.ltr));
|
||||
return Container(color: Colors.green, child: Text('$i', textDirection: TextDirection.ltr));
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
|
@ -102,21 +103,27 @@ void main() {
|
|||
' │ │ diagnosis: insufficient data to draw conclusion (less than five\n'
|
||||
' │ │ repaints)\n'
|
||||
' │ │\n'
|
||||
' │ └─child: RenderParagraph#00000\n'
|
||||
' │ └─child: _RenderColoredBox#00000\n'
|
||||
' │ │ parentData: <none> (can use size)\n'
|
||||
' │ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
|
||||
' │ │ semantics node: SemanticsNode#2\n'
|
||||
' │ │ size: Size(800.0, 600.0)\n'
|
||||
' │ │ textAlign: start\n'
|
||||
' │ │ textDirection: ltr\n'
|
||||
' │ │ softWrap: wrapping at box width\n'
|
||||
' │ │ overflow: clip\n'
|
||||
' │ │ maxLines: unlimited\n'
|
||||
' │ ╘═╦══ text ═══\n'
|
||||
' │ ║ TextSpan:\n'
|
||||
' │ ║ <all styles inherited>\n'
|
||||
' │ ║ "0"\n'
|
||||
' │ ╚═══════════\n'
|
||||
' │ │ behavior: opaque\n'
|
||||
' │ │\n'
|
||||
' │ └─child: RenderParagraph#00000\n'
|
||||
' │ │ parentData: <none> (can use size)\n'
|
||||
' │ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
|
||||
' │ │ semantics node: SemanticsNode#2\n'
|
||||
' │ │ size: Size(800.0, 600.0)\n'
|
||||
' │ │ textAlign: start\n'
|
||||
' │ │ textDirection: ltr\n'
|
||||
' │ │ softWrap: wrapping at box width\n'
|
||||
' │ │ overflow: clip\n'
|
||||
' │ │ maxLines: unlimited\n'
|
||||
' │ ╘═╦══ text ═══\n'
|
||||
' │ ║ TextSpan:\n'
|
||||
' │ ║ <all styles inherited>\n'
|
||||
' │ ║ "0"\n'
|
||||
' │ ╚═══════════\n'
|
||||
' └─child with index 1: RenderRepaintBoundary#00000\n'
|
||||
' │ needs compositing\n'
|
||||
' │ parentData: index=1; layoutOffset=600.0\n'
|
||||
|
@ -127,22 +134,27 @@ void main() {
|
|||
' │ diagnosis: insufficient data to draw conclusion (less than five\n'
|
||||
' │ repaints)\n'
|
||||
' │\n'
|
||||
' └─child: RenderParagraph#00000\n'
|
||||
' └─child: _RenderColoredBox#00000\n'
|
||||
' │ parentData: <none> (can use size)\n'
|
||||
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
|
||||
' │ semantics node: SemanticsNode#3\n'
|
||||
' │ size: Size(800.0, 600.0)\n'
|
||||
' │ textAlign: start\n'
|
||||
' │ textDirection: ltr\n'
|
||||
' │ softWrap: wrapping at box width\n'
|
||||
' │ overflow: clip\n'
|
||||
' │ maxLines: unlimited\n'
|
||||
' ╘═╦══ text ═══\n'
|
||||
' ║ TextSpan:\n'
|
||||
' ║ <all styles inherited>\n'
|
||||
' ║ "1"\n'
|
||||
' ╚═══════════\n'
|
||||
''
|
||||
' │ behavior: opaque\n'
|
||||
' │\n'
|
||||
' └─child: RenderParagraph#00000\n'
|
||||
' │ parentData: <none> (can use size)\n'
|
||||
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
|
||||
' │ semantics node: SemanticsNode#3\n'
|
||||
' │ size: Size(800.0, 600.0)\n'
|
||||
' │ textAlign: start\n'
|
||||
' │ textDirection: ltr\n'
|
||||
' │ softWrap: wrapping at box width\n'
|
||||
' │ overflow: clip\n'
|
||||
' │ maxLines: unlimited\n'
|
||||
' ╘═╦══ text ═══\n'
|
||||
' ║ TextSpan:\n'
|
||||
' ║ <all styles inherited>\n'
|
||||
' ║ "1"\n'
|
||||
' ╚═══════════\n'
|
||||
),
|
||||
);
|
||||
});
|
||||
|
@ -150,7 +162,7 @@ void main() {
|
|||
testWidgets('SliverFillViewport padding test', (WidgetTester tester) async {
|
||||
final SliverChildListDelegate delegate = SliverChildListDelegate(
|
||||
<Widget>[
|
||||
Container(child: const Text('0')),
|
||||
const Text('0'),
|
||||
],
|
||||
addAutomaticKeepAlives: false,
|
||||
addSemanticIndexes: false,
|
||||
|
|
|
@ -389,10 +389,10 @@ void main() {
|
|||
),
|
||||
delegate: SliverChildListDelegate(
|
||||
<Widget>[
|
||||
Container(child: const Center(child: Text('A'))),
|
||||
Container(child: const Center(child: Text('B'))),
|
||||
Container(child: const Center(child: Text('C'))),
|
||||
Container(child: const Center(child: Text('D'))),
|
||||
const Center(child: Text('A')),
|
||||
const Center(child: Text('B')),
|
||||
const Center(child: Text('C')),
|
||||
const Center(child: Text('D')),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -952,15 +952,13 @@ void main() {
|
|||
SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
return Container(
|
||||
child: Material(
|
||||
color: index.isEven ? Colors.yellow : Colors.red,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
index.isEven ? firstTapped++ : secondTapped++;
|
||||
},
|
||||
child: Text('Index $index'),
|
||||
),
|
||||
return Material(
|
||||
color: index.isEven ? Colors.yellow : Colors.red,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
index.isEven ? firstTapped++ : secondTapped++;
|
||||
},
|
||||
child: Text('Index $index'),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
|
@ -51,7 +52,9 @@ void main() {
|
|||
testWidgets('no change', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
color: Colors.blue,
|
||||
child: Container(
|
||||
color: Colors.blue,
|
||||
child: TestWidget(
|
||||
persistentState: 1,
|
||||
syncedState: 0,
|
||||
|
@ -68,7 +71,9 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
color: Colors.blue,
|
||||
child: Container(
|
||||
color: Colors.blue,
|
||||
child: TestWidget(
|
||||
persistentState: 2,
|
||||
syncedState: 0,
|
||||
|
@ -87,7 +92,9 @@ void main() {
|
|||
testWidgets('remove one', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
color: Colors.blue,
|
||||
child: Container(
|
||||
color: Colors.blue,
|
||||
child: TestWidget(
|
||||
persistentState: 10,
|
||||
syncedState: 0,
|
||||
|
@ -104,6 +111,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
color: Colors.green,
|
||||
child: TestWidget(
|
||||
persistentState: 11,
|
||||
syncedState: 0,
|
||||
|
|
|
@ -872,14 +872,12 @@ void main() {
|
|||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: Container(
|
||||
// Each word takes up more than a half of a line. Together they
|
||||
// wrap onto two lines, but leave a lot of extra space.
|
||||
child: Text(
|
||||
'twowordsthateachtakeupmorethanhalfof alineoftextsothattheywrapwithlotsofextraspace',
|
||||
textDirection: TextDirection.ltr,
|
||||
textWidthBasis: textWidthBasis,
|
||||
),
|
||||
// Each word takes up more than a half of a line. Together they
|
||||
// wrap onto two lines, but leave a lot of extra space.
|
||||
child: Text(
|
||||
'twowordsthateachtakeupmorethanhalfof alineoftextsothattheywrapwithlotsofextraspace',
|
||||
textDirection: TextDirection.ltr,
|
||||
textWidthBasis: textWidthBasis,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -98,9 +98,7 @@ void main() {
|
|||
|
||||
testWidgets('SingleTickerProviderStateMixin dispose while active', (WidgetTester tester) async {
|
||||
final GlobalKey<_SingleTickerTestState> key = GlobalKey<_SingleTickerTestState>();
|
||||
final Widget widget = Container(
|
||||
child: _SingleTickerTest(key: key),
|
||||
);
|
||||
final Widget widget = _SingleTickerTest(key: key);
|
||||
await tester.pumpWidget(widget);
|
||||
FlutterError? error;
|
||||
key.currentState!.controller.repeat();
|
||||
|
@ -141,9 +139,7 @@ void main() {
|
|||
|
||||
testWidgets('SingleTickerProviderStateMixin dispose while active', (WidgetTester tester) async {
|
||||
final GlobalKey<_SingleTickerTestState> key = GlobalKey<_SingleTickerTestState>();
|
||||
final Widget widget = Container(
|
||||
child: _SingleTickerTest(key: key),
|
||||
);
|
||||
final Widget widget = _SingleTickerTest(key: key);
|
||||
await tester.pumpWidget(widget);
|
||||
FlutterError? error;
|
||||
key.currentState!.controller.repeat();
|
||||
|
@ -184,9 +180,7 @@ void main() {
|
|||
|
||||
testWidgets('ProviderStateMixin dispose while any ticker is active', (WidgetTester tester) async {
|
||||
final GlobalKey<_MultipleTickerTestState> key = GlobalKey<_MultipleTickerTestState>();
|
||||
final Widget widget = Container(
|
||||
child: _MultipleTickerTest(key: key),
|
||||
);
|
||||
final Widget widget = _MultipleTickerTest(key: key);
|
||||
await tester.pumpWidget(widget);
|
||||
FlutterError? error;
|
||||
key.currentState!.controllers.first.repeat();
|
||||
|
|
|
@ -61,11 +61,9 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
child: OutlinedButton(
|
||||
onPressed: () { },
|
||||
child: const Text('hello'),
|
||||
),
|
||||
body: OutlinedButton(
|
||||
onPressed: () { },
|
||||
child: const Text('hello'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -83,11 +81,9 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
child: OutlinedButton(
|
||||
onPressed: () { },
|
||||
child: const Text('hello'),
|
||||
),
|
||||
body: OutlinedButton(
|
||||
onPressed: () { },
|
||||
child: const Text('hello'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -717,7 +713,7 @@ void main() {
|
|||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
// ListTile does not support horizontal list
|
||||
itemBuilder: (BuildContext context, int i) => Container(child: Text('Item $i')),
|
||||
itemBuilder: (BuildContext context, int i) => Text('Item $i'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -153,9 +153,7 @@ void main() {
|
|||
key: key1,
|
||||
child: const Text('1'),
|
||||
),
|
||||
Container(
|
||||
child: const Text('2'),
|
||||
),
|
||||
const Text('2'),
|
||||
],
|
||||
)),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue