Unnecessary new (#20138)
* enable lint unnecessary_new * fix tests * fix tests * fix tests
This commit is contained in:
committed by
GitHub
parent
d7a0dcaa4a
commit
d927c93310
@@ -7,7 +7,7 @@ import 'package:flutter/scheduler.dart' show timeDilation;
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
new ComplexLayoutApp()
|
||||
ComplexLayoutApp()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ enum ScrollMode { complex, tile }
|
||||
|
||||
class ComplexLayoutApp extends StatefulWidget {
|
||||
@override
|
||||
ComplexLayoutAppState createState() => new ComplexLayoutAppState();
|
||||
ComplexLayoutAppState createState() => ComplexLayoutAppState();
|
||||
|
||||
static ComplexLayoutAppState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher<ComplexLayoutAppState>());
|
||||
}
|
||||
@@ -23,8 +23,8 @@ class ComplexLayoutApp extends StatefulWidget {
|
||||
class ComplexLayoutAppState extends State<ComplexLayoutApp> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
theme: lightTheme ? new ThemeData.light() : new ThemeData.dark(),
|
||||
return MaterialApp(
|
||||
theme: lightTheme ? ThemeData.light() : ThemeData.dark(),
|
||||
title: 'Advanced Layout',
|
||||
home: scrollMode == ScrollMode.complex ? const ComplexLayout() : const TileScrollLayout());
|
||||
}
|
||||
@@ -57,18 +57,18 @@ class TileScrollLayout extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: const Text('Tile Scrolling Layout')),
|
||||
body: new ListView.builder(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Tile Scrolling Layout')),
|
||||
body: ListView.builder(
|
||||
key: const Key('tiles-scroll'),
|
||||
itemCount: 200,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: new Material(
|
||||
child: Material(
|
||||
elevation: (index % 5 + 1).toDouble(),
|
||||
color: Colors.white,
|
||||
child: new IconBar(),
|
||||
child: IconBar(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class ComplexLayout extends StatefulWidget {
|
||||
const ComplexLayout({ Key key }) : super(key: key);
|
||||
|
||||
@override
|
||||
ComplexLayoutState createState() => new ComplexLayoutState();
|
||||
ComplexLayoutState createState() => ComplexLayoutState();
|
||||
|
||||
static ComplexLayoutState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher<ComplexLayoutState>());
|
||||
}
|
||||
@@ -90,34 +90,34 @@ class ComplexLayout extends StatefulWidget {
|
||||
class ComplexLayoutState extends State<ComplexLayout> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Advanced Layout'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.create),
|
||||
tooltip: 'Search',
|
||||
onPressed: () {
|
||||
print('Pressed search');
|
||||
},
|
||||
),
|
||||
new TopBarMenu()
|
||||
TopBarMenu()
|
||||
]
|
||||
),
|
||||
body: new Column(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new ListView.builder(
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
key: const Key('complex-scroll'), // this key is used by the driver test
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index % 2 == 0)
|
||||
return new FancyImageItem(index, key: new PageStorageKey<int>(index));
|
||||
return FancyImageItem(index, key: PageStorageKey<int>(index));
|
||||
else
|
||||
return new FancyGalleryItem(index, key: new PageStorageKey<int>(index));
|
||||
return FancyGalleryItem(index, key: PageStorageKey<int>(index));
|
||||
},
|
||||
)
|
||||
),
|
||||
new BottomBar(),
|
||||
BottomBar(),
|
||||
],
|
||||
),
|
||||
drawer: const GalleryDrawer(),
|
||||
@@ -128,7 +128,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
||||
class TopBarMenu extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new PopupMenuButton<String>(
|
||||
return PopupMenuButton<String>(
|
||||
onSelected: (String value) { print('Selected: $value'); },
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
@@ -185,14 +185,14 @@ class MenuItemWithIcon extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Row(
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
new Icon(icon),
|
||||
new Padding(
|
||||
Icon(icon),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: new Text(title)
|
||||
child: Text(title)
|
||||
),
|
||||
new Text(subtitle, style: Theme.of(context).textTheme.caption)
|
||||
Text(subtitle, style: Theme.of(context).textTheme.caption)
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -205,18 +205,18 @@ class FancyImageItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new ListBody(
|
||||
return ListBody(
|
||||
children: <Widget>[
|
||||
new UserHeader('Ali Connors $index'),
|
||||
new ItemDescription(),
|
||||
new ItemImageBox(),
|
||||
new InfoBar(),
|
||||
UserHeader('Ali Connors $index'),
|
||||
ItemDescription(),
|
||||
ItemImageBox(),
|
||||
InfoBar(),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Divider()
|
||||
),
|
||||
new IconBar(),
|
||||
new FatDivider()
|
||||
IconBar(),
|
||||
FatDivider()
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -228,17 +228,17 @@ class FancyGalleryItem extends StatelessWidget {
|
||||
final int index;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new ListBody(
|
||||
return ListBody(
|
||||
children: <Widget>[
|
||||
const UserHeader('Ali Connors'),
|
||||
new ItemGalleryBox(index),
|
||||
new InfoBar(),
|
||||
ItemGalleryBox(index),
|
||||
InfoBar(),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Divider()
|
||||
),
|
||||
new IconBar(),
|
||||
new FatDivider()
|
||||
IconBar(),
|
||||
FatDivider()
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -247,13 +247,13 @@ class FancyGalleryItem extends StatelessWidget {
|
||||
class InfoBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
const MiniIconWithText(Icons.thumb_up, '42'),
|
||||
new Text('3 Comments', style: Theme.of(context).textTheme.caption)
|
||||
Text('3 Comments', style: Theme.of(context).textTheme.caption)
|
||||
]
|
||||
)
|
||||
);
|
||||
@@ -263,9 +263,9 @@ class InfoBar extends StatelessWidget {
|
||||
class IconBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: const <Widget>[
|
||||
IconWithText(Icons.thumb_up, 'Like'),
|
||||
@@ -285,14 +285,14 @@ class IconWithText extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Row(
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
icon: new Icon(icon),
|
||||
IconButton(
|
||||
icon: Icon(icon),
|
||||
onPressed: () { print('Pressed $title button'); }
|
||||
),
|
||||
new Text(title)
|
||||
Text(title)
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -306,22 +306,22 @@ class MiniIconWithText extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Row(
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: new Container(
|
||||
child: Container(
|
||||
width: 16.0,
|
||||
height: 16.0,
|
||||
decoration: new BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
shape: BoxShape.circle
|
||||
),
|
||||
child: new Icon(icon, color: Colors.white, size: 12.0)
|
||||
child: Icon(icon, color: Colors.white, size: 12.0)
|
||||
)
|
||||
),
|
||||
new Text(title, style: Theme.of(context).textTheme.caption)
|
||||
Text(title, style: Theme.of(context).textTheme.caption)
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -330,7 +330,7 @@ class MiniIconWithText extends StatelessWidget {
|
||||
class FatDivider extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
return Container(
|
||||
height: 8.0,
|
||||
color: Theme.of(context).dividerColor,
|
||||
);
|
||||
@@ -344,9 +344,9 @@ class UserHeader extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Padding(
|
||||
@@ -357,29 +357,29 @@ class UserHeader extends StatelessWidget {
|
||||
height: 32.0
|
||||
)
|
||||
),
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new RichText(text: new TextSpan(
|
||||
RichText(text: TextSpan(
|
||||
style: Theme.of(context).textTheme.body1,
|
||||
children: <TextSpan>[
|
||||
new TextSpan(text: userName, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
TextSpan(text: userName, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
const TextSpan(text: ' shared a new '),
|
||||
const TextSpan(text: 'photo', style: TextStyle(fontWeight: FontWeight.bold))
|
||||
]
|
||||
)),
|
||||
new Row(
|
||||
Row(
|
||||
children: <Widget>[
|
||||
new Text('Yesterday at 11:55 • ', style: Theme.of(context).textTheme.caption),
|
||||
new Icon(Icons.people, size: 16.0, color: Theme.of(context).textTheme.caption.color)
|
||||
Text('Yesterday at 11:55 • ', style: Theme.of(context).textTheme.caption),
|
||||
Icon(Icons.people, size: 16.0, color: Theme.of(context).textTheme.caption.color)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
new TopBarMenu()
|
||||
TopBarMenu()
|
||||
]
|
||||
)
|
||||
);
|
||||
@@ -399,13 +399,13 @@ class ItemDescription extends StatelessWidget {
|
||||
class ItemImageBox extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Card(
|
||||
child: new Column(
|
||||
child: Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new Stack(
|
||||
Stack(
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 230.0,
|
||||
@@ -413,29 +413,29 @@ class ItemImageBox extends StatelessWidget {
|
||||
image: AssetImage('packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png')
|
||||
)
|
||||
),
|
||||
new Theme(
|
||||
data: new ThemeData.dark(),
|
||||
child: new Row(
|
||||
Theme(
|
||||
data: ThemeData.dark(),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: () { print('Pressed edit button'); }
|
||||
),
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.zoom_in),
|
||||
onPressed: () { print('Pressed zoom button'); }
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
new Positioned(
|
||||
Positioned(
|
||||
bottom: 4.0,
|
||||
left: 4.0,
|
||||
child: new Container(
|
||||
decoration: new BoxDecoration(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black54,
|
||||
borderRadius: new BorderRadius.circular(2.0)
|
||||
borderRadius: BorderRadius.circular(2.0)
|
||||
),
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: const RichText(
|
||||
@@ -457,14 +457,14 @@ class ItemImageBox extends StatelessWidget {
|
||||
]
|
||||
)
|
||||
,
|
||||
new Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new Text('Artisans of Southern India', style: Theme.of(context).textTheme.body2),
|
||||
new Text('Silk Spinners', style: Theme.of(context).textTheme.body1),
|
||||
new Text('Sivaganga, Tamil Nadu', style: Theme.of(context).textTheme.caption)
|
||||
Text('Artisans of Southern India', style: Theme.of(context).textTheme.body2),
|
||||
Text('Silk Spinners', style: Theme.of(context).textTheme.body1),
|
||||
Text('Sivaganga, Tamil Nadu', style: Theme.of(context).textTheme.caption)
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -486,44 +486,44 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
'A', 'B', 'C', 'D'
|
||||
];
|
||||
|
||||
return new SizedBox(
|
||||
return SizedBox(
|
||||
height: 200.0,
|
||||
child: new DefaultTabController(
|
||||
child: DefaultTabController(
|
||||
length: tabNames.length,
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new TabBarView(
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
children: tabNames.map((String tabName) {
|
||||
return new Container(
|
||||
key: new PageStorageKey<String>(tabName),
|
||||
child: new Padding(
|
||||
return Container(
|
||||
key: PageStorageKey<String>(tabName),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Card(
|
||||
child: new Column(
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new Container(
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Theme.of(context).primaryColor,
|
||||
child: new Center(
|
||||
child: new Text(tabName, style: Theme.of(context).textTheme.headline.copyWith(color: Colors.white)),
|
||||
child: Center(
|
||||
child: Text(tabName, style: Theme.of(context).textTheme.headline.copyWith(color: Colors.white)),
|
||||
)
|
||||
)
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.share),
|
||||
onPressed: () { print('Pressed share'); },
|
||||
),
|
||||
new IconButton(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.event),
|
||||
onPressed: () { print('Pressed event'); },
|
||||
),
|
||||
new Expanded(
|
||||
child: new Padding(
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text('This is item $tabName'),
|
||||
child: Text('This is item $tabName'),
|
||||
)
|
||||
)
|
||||
]
|
||||
@@ -536,7 +536,7 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
}).toList()
|
||||
)
|
||||
),
|
||||
new Container(
|
||||
Container(
|
||||
child: const TabPageSelector()
|
||||
)
|
||||
]
|
||||
@@ -549,16 +549,16 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
class BottomBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(
|
||||
top: new BorderSide(
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0
|
||||
)
|
||||
)
|
||||
),
|
||||
child: new Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: const <Widget>[
|
||||
BottomBarButton(Icons.new_releases, 'News'),
|
||||
@@ -580,15 +580,15 @@ class BottomBarButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
icon: new Icon(icon),
|
||||
IconButton(
|
||||
icon: Icon(icon),
|
||||
onPressed: () { print('Pressed: $title'); }
|
||||
),
|
||||
new Text(title, style: Theme.of(context).textTheme.caption)
|
||||
Text(title, style: Theme.of(context).textTheme.caption)
|
||||
]
|
||||
)
|
||||
);
|
||||
@@ -609,49 +609,49 @@ class GalleryDrawer extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ScrollMode currentMode = ComplexLayoutApp.of(context).scrollMode;
|
||||
return new Drawer(
|
||||
return Drawer(
|
||||
// Note: for real apps, see the Gallery material Drawer demo. More
|
||||
// typically, a drawer would have a fixed header with a scrolling body
|
||||
// below it.
|
||||
child: new ListView(
|
||||
child: ListView(
|
||||
key: const PageStorageKey<String>('gallery-drawer'),
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
new FancyDrawerHeader(),
|
||||
new ListTile(
|
||||
FancyDrawerHeader(),
|
||||
ListTile(
|
||||
key: const Key('scroll-switcher'),
|
||||
onTap: () { _changeScrollMode(context, currentMode == ScrollMode.complex ? ScrollMode.tile : ScrollMode.complex); },
|
||||
trailing: new Text(currentMode == ScrollMode.complex ? 'Tile' : 'Complex')
|
||||
trailing: Text(currentMode == ScrollMode.complex ? 'Tile' : 'Complex')
|
||||
),
|
||||
new ListTile(
|
||||
ListTile(
|
||||
leading: const Icon(Icons.brightness_5),
|
||||
title: const Text('Light'),
|
||||
onTap: () { _changeTheme(context, true); },
|
||||
selected: ComplexLayoutApp.of(context).lightTheme,
|
||||
trailing: new Radio<bool>(
|
||||
trailing: Radio<bool>(
|
||||
value: true,
|
||||
groupValue: ComplexLayoutApp.of(context).lightTheme,
|
||||
onChanged: (bool value) { _changeTheme(context, value); }
|
||||
),
|
||||
),
|
||||
new ListTile(
|
||||
ListTile(
|
||||
leading: const Icon(Icons.brightness_7),
|
||||
title: const Text('Dark'),
|
||||
onTap: () { _changeTheme(context, false); },
|
||||
selected: !ComplexLayoutApp.of(context).lightTheme,
|
||||
trailing: new Radio<bool>(
|
||||
trailing: Radio<bool>(
|
||||
value: false,
|
||||
groupValue: ComplexLayoutApp.of(context).lightTheme,
|
||||
onChanged: (bool value) { _changeTheme(context, value); },
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
new ListTile(
|
||||
ListTile(
|
||||
leading: const Icon(Icons.hourglass_empty),
|
||||
title: const Text('Animate Slowly'),
|
||||
selected: timeDilation != 1.0,
|
||||
onTap: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); },
|
||||
trailing: new Checkbox(
|
||||
trailing: Checkbox(
|
||||
value: timeDilation != 1.0,
|
||||
onChanged: (bool value) { ComplexLayoutApp.of(context).toggleAnimationSpeed(); }
|
||||
),
|
||||
@@ -665,7 +665,7 @@ class GalleryDrawer extends StatelessWidget {
|
||||
class FancyDrawerHeader extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
return Container(
|
||||
color: Colors.purple,
|
||||
height: 200.0,
|
||||
child: const SafeArea(
|
||||
|
||||
@@ -25,7 +25,7 @@ void main() {
|
||||
// period of increased load on the device. Without this delay, the
|
||||
// benchmark has greater noise.
|
||||
// See: https://github.com/flutter/flutter/issues/19434
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 250));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 250));
|
||||
final Timeline timeline = await driver.traceAction(() async {
|
||||
// Find the scrollable stock list
|
||||
final SerializableFinder list = find.byValueKey(listKey);
|
||||
@@ -34,17 +34,17 @@ void main() {
|
||||
// Scroll down
|
||||
for (int i = 0; i < 5; i += 1) {
|
||||
await driver.scroll(list, 0.0, -300.0, const Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
// Scroll up
|
||||
for (int i = 0; i < 5; i += 1) {
|
||||
await driver.scroll(list, 0.0, 300.0, const Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
});
|
||||
|
||||
final TimelineSummary summary = new TimelineSummary.summarize(timeline);
|
||||
final TimelineSummary summary = TimelineSummary.summarize(timeline);
|
||||
summary.writeSummaryToFile(summaryName, pretty: true);
|
||||
summary.writeTimelineToFile(summaryName, pretty: true);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ void main() {
|
||||
|
||||
test('inital tree creation', () async {
|
||||
// Let app become fully idle.
|
||||
await new Future<Null>.delayed(const Duration(seconds: 1));
|
||||
await Future<Null>.delayed(const Duration(seconds: 1));
|
||||
|
||||
final Timeline timeline = await driver.traceAction(() async {
|
||||
expect(await driver.setSemantics(true), isTrue);
|
||||
@@ -37,7 +37,7 @@ void main() {
|
||||
final Duration semanticsTreeCreation = semanticsEvents.first.duration;
|
||||
|
||||
final String jsonEncoded = json.encode(<String, dynamic>{'initialSemanticsTreeCreation': semanticsTreeCreation.inMilliseconds});
|
||||
new File(p.join(testOutputsDirectory, 'complex_layout_semantics_perf.json')).writeAsStringSync(jsonEncoded);
|
||||
File(p.join(testOutputsDirectory, 'complex_layout_semantics_perf.json')).writeAsStringSync(jsonEncoded);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ const int maxIterations = 4;
|
||||
const Duration pauses = Duration(milliseconds: 500);
|
||||
|
||||
Future<void> main() async {
|
||||
final Completer<void> ready = new Completer<void>();
|
||||
runApp(new GestureDetector(
|
||||
final Completer<void> ready = Completer<void>();
|
||||
runApp(GestureDetector(
|
||||
onTap: () {
|
||||
debugPrint('Received tap.');
|
||||
ready.complete();
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: new IgnorePointer(
|
||||
child: IgnorePointer(
|
||||
ignoring: true,
|
||||
child: new ComplexLayoutApp(),
|
||||
child: ComplexLayoutApp(),
|
||||
),
|
||||
));
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
@@ -37,35 +37,35 @@ Future<void> main() async {
|
||||
/// Wait 50ms to allow the GPU thread to actually put up the frame. (The
|
||||
/// endOfFrame future ends when we send the data to the engine, before the GPU
|
||||
/// thread has had a chance to rasterize, etc.)
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 50));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 50));
|
||||
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
|
||||
|
||||
await ready.future; // waits for tap sent by devicelab task
|
||||
debugPrint('Continuing...');
|
||||
|
||||
// remove onTap handler, enable pointer events for app
|
||||
runApp(new GestureDetector(
|
||||
child: new IgnorePointer(
|
||||
runApp(GestureDetector(
|
||||
child: IgnorePointer(
|
||||
ignoring: false,
|
||||
child: new ComplexLayoutApp(),
|
||||
child: ComplexLayoutApp(),
|
||||
),
|
||||
));
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
|
||||
final WidgetController controller = new LiveWidgetController(WidgetsBinding.instance);
|
||||
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance);
|
||||
|
||||
// Scroll down
|
||||
for (int iteration = 0; iteration < maxIterations; iteration += 1) {
|
||||
debugPrint('Scroll down... $iteration/$maxIterations');
|
||||
await controller.fling(find.byType(ListView), const Offset(0.0, -700.0), speed);
|
||||
await new Future<Null>.delayed(pauses);
|
||||
await Future<Null>.delayed(pauses);
|
||||
}
|
||||
|
||||
// Scroll up
|
||||
for (int iteration = 0; iteration < maxIterations; iteration += 1) {
|
||||
debugPrint('Scroll up... $iteration/$maxIterations');
|
||||
await controller.fling(find.byType(ListView), const Offset(0.0, 300.0), speed);
|
||||
await new Future<Null>.delayed(pauses);
|
||||
await Future<Null>.delayed(pauses);
|
||||
}
|
||||
|
||||
debugPrint('==== MEMORY BENCHMARK ==== DONE ====');
|
||||
|
||||
Reference in New Issue
Block a user