add missing type parameter on methods (#22096)

This commit is contained in:
Alexandre Ardhuin
2018-10-01 21:29:08 +02:00
committed by GitHub
parent 48fb726b01
commit f62afdcf57
211 changed files with 504 additions and 503 deletions

View File

@@ -89,7 +89,7 @@ class SampleInfo {
final String classNames = commentValues['classes'];
if (classNames == null)
return const <String>[];
return classNames.split(',').map((String s) => s.trim()).where((String s) => s.isNotEmpty);
return classNames.split(',').map<String>((String s) => s.trim()).where((String s) => s.isNotEmpty);
}
// The relative import path for this sample, like '../lib/foo.dart'.
@@ -163,7 +163,7 @@ void generate(String commit) {
final String entryTemplate = inputFile('bin', 'entry.md.template').readAsStringSync();
// Write the sample catalog's home page: index.md
final Iterable<String> entries = samples.map((SampleInfo sample) {
final Iterable<String> entries = samples.map<String>((SampleInfo sample) {
return expandTemplate(entryTemplate, sample.commentValues);
});
writeExpandedTemplate(
@@ -195,7 +195,7 @@ void generate(String commit) {
}
}
for (String className in classToSamples.keys) {
final Iterable<String> entries = classToSamples[className].map((SampleInfo sample) {
final Iterable<String> entries = classToSamples[className].map<String>((SampleInfo sample) {
return expandTemplate(entryTemplate, sample.commentValues);
});
writeExpandedTemplate(
@@ -215,10 +215,10 @@ void generate(String commit) {
outputFile('screenshot.dart', driverDirectory),
inputFile('bin', 'screenshot.dart.template').readAsStringSync(),
<String, String>{
'imports': samples.map((SampleInfo page) {
'imports': samples.map<String>((SampleInfo page) {
return "import '${page.importPath}' show ${page.sampleClass};\n";
}).toList().join(),
'widgets': samples.map((SampleInfo sample) {
'widgets': samples.map<String>((SampleInfo sample) {
return 'new ${sample.sampleClass}(),\n';
}).toList().join(),
},
@@ -230,7 +230,7 @@ void generate(String commit) {
outputFile('screenshot_test.dart', driverDirectory),
inputFile('bin', 'screenshot_test.dart.template').readAsStringSync(),
<String, String>{
'paths': samples.map((SampleInfo sample) {
'paths': samples.map<String>((SampleInfo sample) {
return "'${outputFile(sample.sourceName + '.png').path}'";
}).toList().join(',\n'),
},

View File

@@ -63,7 +63,7 @@ class _AppBarBottomSampleState extends State<AppBarBottomSample> with SingleTick
),
body: TabBarView(
controller: _tabController,
children: choices.map((Choice choice) {
children: choices.map<Widget>((Choice choice) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: ChoiceCard(choice: choice),

View File

@@ -37,7 +37,7 @@ class _BasicAppBarSampleState extends State<BasicAppBarSample> {
PopupMenuButton<Choice>( // overflow menu
onSelected: _select,
itemBuilder: (BuildContext context) {
return choices.skip(2).map((Choice choice) {
return choices.skip(2).map<PopupMenuItem<Choice>>((Choice choice) {
return PopupMenuItem<Choice>(
value: choice,
child: Text(choice.title),

View File

@@ -50,7 +50,7 @@ class AdjustableDropdownListTile extends StatelessWidget {
trailing: DropdownButton<String>(
value: value,
onChanged: onChanged,
items: items.map((String item) {
items: items.map<DropdownMenuItem<String>>((String item) {
return DropdownMenuItem<String>(
value: item,
child: Text(item),

View File

@@ -78,7 +78,7 @@ class EntryItem extends StatelessWidget {
return ExpansionTile(
key: PageStorageKey<Entry>(root),
title: Text(root.title),
children: root.children.map(_buildTiles).toList(),
children: root.children.map<Widget>(_buildTiles).toList(),
);
}

View File

@@ -15,7 +15,7 @@ class TabbedAppBarSample extends StatelessWidget {
title: const Text('Tabbed AppBar'),
bottom: TabBar(
isScrollable: true,
tabs: choices.map((Choice choice) {
tabs: choices.map<Widget>((Choice choice) {
return Tab(
text: choice.title,
icon: Icon(choice.icon),
@@ -24,7 +24,7 @@ class TabbedAppBarSample extends StatelessWidget {
),
),
body: TabBarView(
children: choices.map((Choice choice) {
children: choices.map<Widget>((Choice choice) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: ChoiceCard(choice: choice),

View File

@@ -493,7 +493,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
}
Iterable<Widget> _detailItemsFor(Section section) {
final Iterable<Widget> detailItems = section.details.map((SectionDetail detail) {
final Iterable<Widget> detailItems = section.details.map<Widget>((SectionDetail detail) {
return SectionDetailView(detail: detail);
});
return ListTile.divideTiles(context: context, tiles: detailItems);
@@ -591,7 +591,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
},
child: PageView(
controller: _detailsPageController,
children: allSections.map((Section section) {
children: allSections.map<Widget>((Section section) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: _detailItemsFor(section).toList(),

View File

@@ -99,7 +99,7 @@ class PaletteTabView extends StatelessWidget {
final TextTheme textTheme = Theme.of(context).textTheme;
final TextStyle whiteTextStyle = textTheme.body1.copyWith(color: Colors.white);
final TextStyle blackTextStyle = textTheme.body1.copyWith(color: Colors.black);
final List<Widget> colorItems = primaryKeys.map((int index) {
final List<Widget> colorItems = primaryKeys.map<Widget>((int index) {
return DefaultTextStyle(
style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
child: ColorItem(index: index, color: colors.primary[index]),
@@ -107,7 +107,7 @@ class PaletteTabView extends StatelessWidget {
}).toList();
if (colors.accent != null) {
colorItems.addAll(accentKeys.map((int index) {
colorItems.addAll(accentKeys.map<Widget>((int index) {
return DefaultTextStyle(
style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
child: ColorItem(index: index, color: colors.accent[index], prefix: 'A'),
@@ -135,11 +135,11 @@ class ColorsDemo extends StatelessWidget {
title: const Text('Colors'),
bottom: TabBar(
isScrollable: true,
tabs: allPalettes.map((Palette swatch) => Tab(text: swatch.name)).toList(),
tabs: allPalettes.map<Widget>((Palette swatch) => Tab(text: swatch.name)).toList(),
),
),
body: TabBarView(
children: allPalettes.map((Palette colors) {
children: allPalettes.map<Widget>((Palette colors) {
return PaletteTabView(colors: colors);
}).toList(),
),

View File

@@ -54,7 +54,7 @@ class _ContactItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final List<Widget> columnChildren = lines.sublist(0, lines.length - 1).map((String line) => Text(line)).toList();
final List<Widget> columnChildren = lines.sublist(0, lines.length - 1).map<Widget>((String line) => Text(line)).toList();
columnChildren.add(Text(lines.last, style: themeData.textTheme.caption));
final List<Widget> rowChildren = <Widget>[

View File

@@ -58,7 +58,7 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem
CupertinoSliverRefreshControl(
onRefresh: () {
return Future<void>.delayed(const Duration(seconds: 2))
..then((_) {
..then<void>((_) {
if (mounted) {
setState(() => repopulateList());
}

View File

@@ -281,7 +281,7 @@ class _ColorsItem extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: colors.map((_NamedColor namedColor) {
children: colors.map<Widget>((_NamedColor namedColor) {
return RawMaterialButton(
onPressed: () {
onChanged(namedColor.color);

View File

@@ -194,7 +194,7 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
Widget build(BuildContext context) {
final BottomNavigationBar botNavBar = BottomNavigationBar(
items: _navigationViews
.map((NavigationIconView navigationView) => navigationView.item)
.map<BottomNavigationBarItem>((NavigationIconView navigationView) => navigationView.item)
.toList(),
currentIndex: _currentIndex,
type: _type,

View File

@@ -280,7 +280,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
dropdown1Value = newValue;
});
},
items: <String>['One', 'Two', 'Free', 'Four'].map((String value) {
items: <String>['One', 'Two', 'Free', 'Four'].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
@@ -301,7 +301,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
dropdown2Value = newValue;
});
},
items: <String>['One', 'Two', 'Free', 'Four'].map((String value) {
items: <String>['One', 'Two', 'Free', 'Four'].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
@@ -325,7 +325,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
'One', 'Two', 'Free', 'Four', 'Can', 'I', 'Have', 'A', 'Little',
'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'
]
.map((String value) {
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
@@ -365,7 +365,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
onPressed: null,
)
]
.map((Widget button) => SizedBox(width: 64.0, height: 64.0, child: button))
.map<Widget>((Widget button) => SizedBox(width: 64.0, height: 64.0, child: button))
.toList(),
),
);

View File

@@ -191,7 +191,7 @@ class _CardsDemoState extends State<CardsDemo> {
body: ListView(
itemExtent: TravelDestinationItem.height,
padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0),
children: destinations.map((TravelDestination destination) {
children: destinations.map<Widget>((TravelDestination destination) {
return Container(
margin: const EdgeInsets.only(bottom: 8.0),
child: TravelDestinationItem(

View File

@@ -92,7 +92,7 @@ class _ChipsTile extends StatelessWidget {
];
if (children.isNotEmpty) {
cardChildren.add(Wrap(
children: children.map((Widget chip) {
children: children.map<Widget>((Widget chip) {
return Padding(
padding: const EdgeInsets.all(2.0),
child: chip,

View File

@@ -201,7 +201,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
_activity = newValue;
});
},
items: _allActivities.map((String value) {
items: _allActivities.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),

View File

@@ -201,7 +201,7 @@ class DialogDemoState extends State<DialogDemo> {
),
]
// Add a little space between the buttons
.map((Widget button) {
.map<Widget>((Widget button) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: button

View File

@@ -159,7 +159,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: _drawerContents.map((String id) {
children: _drawerContents.map<Widget>((String id) {
return ListTile(
leading: CircleAvatar(child: Text(id)),
title: Text('Drawer item $id'),

View File

@@ -25,7 +25,7 @@ class _ElevationDemoState extends State<ElevationDemo> {
24.0,
];
return elevations.map((double elevation) {
return elevations.map<Widget>((double elevation) {
return Center(
child: Card(
margin: const EdgeInsets.all(20.0),

View File

@@ -356,7 +356,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
_demoItems[index].isExpanded = !isExpanded;
});
},
children: _demoItems.map((DemoItem<dynamic> item) {
children: _demoItems.map<ExpansionPanel>((DemoItem<dynamic> item) {
return ExpansionPanel(
isExpanded: item.isExpanded,
headerBuilder: item.headerBuilder,

View File

@@ -251,7 +251,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
)
)
]
.map((Widget child) {
.map<Widget>((Widget child) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
height: 96.0,

View File

@@ -374,7 +374,7 @@ class GridListDemoState extends State<GridListDemo> {
crossAxisSpacing: 4.0,
padding: const EdgeInsets.all(4.0),
childAspectRatio: (orientation == Orientation.portrait) ? 1.0 : 1.3,
children: photos.map((Photo photo) {
children: photos.map<Widget>((Photo photo) {
return GridDemoPhotoItem(
photo: photo,
tileStyle: _tileStyle,

View File

@@ -126,7 +126,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
);
} else {
body = ListView(
children: leaveBehindItems.map((LeaveBehindItem item) {
children: leaveBehindItems.map<Widget>((LeaveBehindItem item) {
return _LeaveBehindListItem(
item: item,
onArchive: _handleArchive,

View File

@@ -209,7 +209,7 @@ class _ListDemoState extends State<ListDemo> {
break;
}
Iterable<Widget> listTiles = items.map((String item) => buildListTile(context, item));
Iterable<Widget> listTiles = items.map<Widget>((String item) => buildListTile(context, item));
if (_showDividers)
listTiles = ListTile.divideTiles(context: context, tiles: listTiles);

View File

@@ -29,7 +29,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
Future<Null> _handleRefresh() {
final Completer<Null> completer = Completer<Null>();
Timer(const Duration(seconds: 3), () { completer.complete(null); });
return completer.future.then((_) {
return completer.future.then<Null>((_) {
_scaffoldKey.currentState?.showSnackBar(SnackBar(
content: const Text('Refresh complete'),
action: SnackBarAction(

View File

@@ -54,7 +54,7 @@ class _PageSelector extends StatelessWidget {
color: color,
),
child: TabBarView(
children: icons.map((Icon icon) {
children: icons.map<Widget>((Icon icon) {
return Container(
padding: const EdgeInsets.all(12.0),
child: Card(

View File

@@ -94,7 +94,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
];
return Column(
children: indicators
.map((Widget c) => Container(child: c, margin: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0)))
.map<Widget>((Widget c) => Container(child: c, margin: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0)))
.toList(),
);
}

View File

@@ -44,7 +44,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
bool _reverseSort = false;
final List<_ListItem> _items = <String>[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
].map((String item) => _ListItem(item, false)).toList();
].map<_ListItem>((String item) => _ListItem(item, false)).toList();
void changeItemType(_ReorderableListType type) {
setState(() {
@@ -191,7 +191,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
onReorder: _onReorder,
scrollDirection: _itemType == _ReorderableListType.horizontalAvatar ? Axis.horizontal : Axis.vertical,
padding: const EdgeInsets.symmetric(vertical: 8.0),
children: _items.map(buildListTile).toList(),
children: _items.map<Widget>(buildListTile).toList(),
),
),
);

View File

@@ -174,7 +174,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
),
body: TabBarView(
controller: _controller,
children: _allPages.map((_Page page) {
children: _allPages.map<Widget>((_Page page) {
return SafeArea(
top: false,
bottom: false,

View File

@@ -160,7 +160,7 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> {
return _SuggestionList(
query: query,
suggestions: suggestions.map((int i) => '$i').toList(),
suggestions: suggestions.map<String>((int i) => '$i').toList(),
onSelected: (String suggestion) {
query = suggestion;
showResults(context);

View File

@@ -60,7 +60,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
),
const Text(_text3),
]
.map((Widget child) {
.map<Widget>((Widget child) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 12.0),
child: child

View File

@@ -157,7 +157,7 @@ class TabsDemo extends StatelessWidget {
expandedHeight: 150.0,
forceElevated: innerBoxIsScrolled,
bottom: TabBar(
tabs: _allPages.keys.map(
tabs: _allPages.keys.map<Widget>(
(_Page page) => Tab(text: page.label),
).toList(),
),
@@ -166,7 +166,7 @@ class TabsDemo extends StatelessWidget {
];
},
body: TabBarView(
children: _allPages.keys.map((_Page page) {
children: _allPages.keys.map<Widget>((_Page page) {
return SafeArea(
top: false,
bottom: false,

View File

@@ -136,7 +136,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
title: const Text('FAB per tab'),
bottom: TabBar(
controller: _controller,
tabs: _allPages.map((_Page page) => Tab(text: page.label.toUpperCase())).toList(),
tabs: _allPages.map<Widget>((_Page page) => Tab(text: page.label.toUpperCase())).toList(),
),
actions: <Widget>[
MaterialDemoDocumentationButton(TabsFabDemo.routeName),
@@ -153,7 +153,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
floatingActionButton: buildFloatingActionButton(_selectedPage),
body: TabBarView(
controller: _controller,
children: _allPages.map(buildTabView).toList()
children: _allPages.map<Widget>(buildTabView).toList()
),
);
}

View File

@@ -59,7 +59,7 @@ class TooltipDemo extends StatelessWidget {
)
)
]
.map((Widget widget) {
.map<Widget>((Widget widget) {
return Padding(
padding: const EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0),
child: widget

View File

@@ -492,7 +492,7 @@ class RecipeSheet extends StatelessWidget {
),
]
),
]..addAll(recipe.ingredients.map(
]..addAll(recipe.ingredients.map<TableRow>(
(RecipeIngredient ingredient) {
return _buildItemRow(ingredient.amount, ingredient.description);
}
@@ -506,7 +506,7 @@ class RecipeSheet extends StatelessWidget {
),
]
)
)..addAll(recipe.steps.map(
)..addAll(recipe.steps.map<TableRow>(
(RecipeStep step) {
return _buildItemRow(step.duration ?? '', step.description);
}

View File

@@ -395,7 +395,7 @@ class _ShrineHomeState extends State<ShrineHome> {
sliver: SliverGrid(
gridDelegate: gridDelegate,
delegate: SliverChildListDelegate(
_products.map((Product product) {
_products.map<Widget>((Product product) {
return _ProductItem(
product: product,
onPressed: () { _showOrderPage(product); },

View File

@@ -46,7 +46,7 @@ class _ProductItem extends StatelessWidget {
),
),
child: DropdownButton<int>(
items: <int>[0, 1, 2, 3, 4, 5].map((int value) {
items: <int>[0, 1, 2, 3, 4, 5].map<DropdownMenuItem<int>>((int value) {
return DropdownMenuItem<int>(
value: value,
child: Padding(

View File

@@ -381,7 +381,7 @@ class _VideoDemoState extends State<VideoDemo>
initController(butterflyController);
initController(beeController);
isIOSSimulator().then((bool result) {
isIOSSimulator().then<void>((bool result) {
isSupported = !result;
});
}

View File

@@ -96,11 +96,11 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
),
bottom: TabBar(
isScrollable: true,
tabs: demos.map((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(),
tabs: demos.map<Widget>((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(),
),
),
body: TabBarView(
children: demos.map((ComponentDemoTabData demo) {
children: demos.map<Widget>((ComponentDemoTabData demo) {
return SafeArea(
top: false,
bottom: false,

View File

@@ -104,7 +104,7 @@ DropdownButton<String>(
});
},
items: <String>['One', 'Two', 'Free', 'Four']
.map((String value) {
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value));
@@ -263,7 +263,7 @@ GridView.count(
'https://example.com/image-2.jpg',
'...',
'https://example.com/image-n.jpg'
].map((String url) {
].map<Widget>((String url) {
return GridTile(
footer: GridTileBar(
title: Text(url)

View File

@@ -252,7 +252,7 @@ class _TextScaleFactorItem extends StatelessWidget {
padding: const EdgeInsetsDirectional.only(end: 16.0),
icon: const Icon(Icons.arrow_drop_down),
itemBuilder: (BuildContext context) {
return kAllGalleryTextScaleValues.map((GalleryTextScaleValue scaleValue) {
return kAllGalleryTextScaleValues.map<PopupMenuItem<GalleryTextScaleValue>>((GalleryTextScaleValue scaleValue) {
return PopupMenuItem<GalleryTextScaleValue>(
value: scaleValue,
child: Text(scaleValue.label),

View File

@@ -141,7 +141,7 @@ class CalculationManager {
final CalculationMessage message = CalculationMessage(data, _receivePort.sendPort);
// Spawn an isolate to JSON-parse the file contents. The JSON parsing
// is synchronous, so if done in the main isolate, the UI would block.
Isolate.spawn(_calculate, message).then<Null>((Isolate isolate) {
Isolate.spawn<CalculationMessage>(_calculate, message).then<Null>((Isolate isolate) {
if (!isRunning) {
isolate.kill(priority: Isolate.immediate);
} else {

View File

@@ -74,12 +74,12 @@ class AdaptiveContainer extends StatelessWidget {
if (MediaQuery.of(context).size.width < _kGridViewBreakpoint) {
return ListView(
itemExtent: _kListItemExtent,
children: names.map((String name) => AdaptedListItem(name: name)).toList(),
children: names.map<Widget>((String name) => AdaptedListItem(name: name)).toList(),
);
} else {
return GridView.extent(
maxCrossAxisExtent: _kMaxTileWidth,
children: names.map((String name) => AdaptedGridItem(name: name)).toList(),
children: names.map<Widget>((String name) => AdaptedGridItem(name: name)).toList(),
);
}
}

View File

@@ -28,7 +28,7 @@ class SectorAppState extends State<SectorApp> {
List<double> wantedSectorSizes = <double>[];
List<double> actualSectorSizes = <double>[];
double get currentTheta => wantedSectorSizes.fold(0.0, (double total, double value) => total + value);
double get currentTheta => wantedSectorSizes.fold<double>(0.0, (double total, double value) => total + value);
void addSector() {
final double currentTheta = this.currentTheta;

View File

@@ -20,7 +20,7 @@ HAL: This mission is too important for me to allow you to jeopardize it.''';
// [["Dave", "Open the pod bay..."] ...]
final List<List<String>> _kNameLines = _kDialogText
.split('\n')
.map((String line) => line.split(':'))
.map<List<String>>((String line) => line.split(':'))
.toList();
final TextStyle _kDaveStyle = TextStyle(color: Colors.indigo.shade400, height: 1.8);

View File

@@ -19,7 +19,7 @@ class StockStrings {
static Future<StockStrings> load(Locale locale) {
return initializeMessages(locale.toString())
.then((Object _) {
.then<StockStrings>((Object _) {
return StockStrings(locale);
});
}