Increase the strictness of our requiring explicit types (#7585)
...now that we have generic methods, their types need to be specified too.
This commit is contained in:
@@ -70,7 +70,7 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
context: context,
|
||||
child: child
|
||||
)
|
||||
.then((T value) { // The value passed to Navigator.pop() or null.
|
||||
.then<Null>((T value) { // The value passed to Navigator.pop() or null.
|
||||
if (value != null) {
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
content: new Text('You selected: $value')
|
||||
@@ -178,7 +178,7 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
context: context,
|
||||
initialTime: _selectedTime
|
||||
)
|
||||
.then((TimeOfDay value) {
|
||||
.then<Null>((TimeOfDay value) {
|
||||
if (value != null && value != _selectedTime) {
|
||||
_selectedTime = value;
|
||||
_scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
|
||||
@@ -48,7 +48,7 @@ class DateTimeItem extends StatelessWidget {
|
||||
firstDate: date.subtract(const Duration(days: 30)),
|
||||
lastDate: date.add(const Duration(days: 30))
|
||||
)
|
||||
.then((DateTime value) {
|
||||
.then<Null>((DateTime value) {
|
||||
onChanged(new DateTime(value.year, value.month, value.day, time.hour, time.minute));
|
||||
});
|
||||
},
|
||||
@@ -74,7 +74,7 @@ class DateTimeItem extends StatelessWidget {
|
||||
context: context,
|
||||
initialTime: time
|
||||
)
|
||||
.then((TimeOfDay value) {
|
||||
.then<Null>((TimeOfDay value) {
|
||||
onChanged(new DateTime(date.year, date.month, date.day, value.hour, value.minute));
|
||||
});
|
||||
},
|
||||
@@ -112,7 +112,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextStyle dialogTextStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
|
||||
|
||||
showDialog(
|
||||
showDialog<DismissDialogAction>(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
content: new Text(
|
||||
|
||||
@@ -22,7 +22,6 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
_showBottomSheetCallback = _showBottomSheet;
|
||||
}
|
||||
|
||||
|
||||
void _showBottomSheet() {
|
||||
setState(() { // disable the button
|
||||
_showBottomSheetCallback = null;
|
||||
@@ -45,15 +44,17 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
)
|
||||
);
|
||||
})
|
||||
.closed.then((_) {
|
||||
setState(() { // re-enable the button
|
||||
_showBottomSheetCallback = _showBottomSheet;
|
||||
});
|
||||
.closed.whenComplete(() {
|
||||
if (mounted) {
|
||||
setState(() { // re-enable the button
|
||||
_showBottomSheetCallback = _showBottomSheet;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _showMessage() {
|
||||
showDialog(
|
||||
showDialog<Null>(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
content: new Text('You tapped the floating action button.'),
|
||||
|
||||
@@ -66,7 +66,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
||||
}
|
||||
|
||||
void _showExplanatoryText() {
|
||||
_scaffoldKey.currentState.showBottomSheet((BuildContext context) {
|
||||
_scaffoldKey.currentState.showBottomSheet<Null>((BuildContext context) {
|
||||
return new Container(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(top: new BorderSide(color: Theme.of(context).dividerColor))
|
||||
|
||||
@@ -110,10 +110,12 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
|
||||
@override
|
||||
void dependenciesChanged() {
|
||||
getExampleCode(config.exampleCodeTag, DefaultAssetBundle.of(context)).then((String code) {
|
||||
setState(() {
|
||||
_exampleCode = code;
|
||||
});
|
||||
getExampleCode(config.exampleCodeTag, DefaultAssetBundle.of(context)).then<Null>((String code) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_exampleCode = code;
|
||||
});
|
||||
}
|
||||
});
|
||||
super.dependenciesChanged();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class TestAssetBundle extends AssetBundle {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> loadStructuredData(String key, Future<dynamic> parser(String value)) async {
|
||||
Future<dynamic> loadStructuredData<T>(String key, Future<T> parser(String value)) async {
|
||||
return parser(await loadString(key));
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ void main() {
|
||||
if (!unsynchedDemoTitles.contains(demoTitle)) {
|
||||
await driver.tap(find.byTooltip('Back'));
|
||||
} else {
|
||||
await driver.runUnsynchronized(() async {
|
||||
await driver.runUnsynchronized<Future<Null>>(() async {
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
await driver.tap(find.byTooltip('Back'));
|
||||
});
|
||||
|
||||
@@ -137,12 +137,12 @@ class CalculationManager {
|
||||
// the root bundle (see https://github.com/flutter/flutter/issues/3294).
|
||||
// However, the loading process is asynchronous, so the UI will not block
|
||||
// while the file is loaded.
|
||||
rootBundle.loadString('services/data.json').then((String data) {
|
||||
rootBundle.loadString('services/data.json').then<Null>((String data) {
|
||||
if (isRunning) {
|
||||
CalculationMessage message = new CalculationMessage(data, _receivePort.sendPort);
|
||||
final CalculationMessage message = new 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((Isolate isolate) {
|
||||
Isolate.spawn(_calculate, message).then<Null>((Isolate isolate) {
|
||||
if (!isRunning) {
|
||||
isolate.kill(priority: Isolate.IMMEDIATE);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef Widget TextTransformer(String name, String text);
|
||||
typedef Widget _TextTransformer(String name, String text);
|
||||
|
||||
// From https://en.wikiquote.org/wiki/2001:_A_Space_Odyssey_(film)
|
||||
const String _kDialogText = '''
|
||||
@@ -84,7 +84,7 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
|
||||
_toText = toStyledText;
|
||||
}
|
||||
|
||||
TextTransformer _toText;
|
||||
_TextTransformer _toText;
|
||||
|
||||
void _handleTap() {
|
||||
setState(() {
|
||||
@@ -95,7 +95,7 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> lines = _kNameLines
|
||||
.map((List<String> nameAndText) => Function.apply(_toText, nameAndText))
|
||||
.map<Widget>((List<String> nameAndText) => _toText(nameAndText[0], nameAndText[1]))
|
||||
.toList();
|
||||
|
||||
List<Widget> children = <Widget>[];
|
||||
|
||||
@@ -72,7 +72,7 @@ class StockDataFetcher {
|
||||
void _fetchNextChunk() {
|
||||
if (!actuallyFetchData)
|
||||
return;
|
||||
http.get(_urlToFetch(_nextChunk++)).then((http.Response response) {
|
||||
http.get(_urlToFetch(_nextChunk++)).then<Null>((http.Response response) {
|
||||
String json = response.body;
|
||||
if (json == null) {
|
||||
print("Failed to load stock data chunk ${_nextChunk - 1}");
|
||||
|
||||
@@ -105,7 +105,7 @@ class StockHomeState extends State<StockHome> {
|
||||
});
|
||||
break;
|
||||
case _StockMenuItem.refresh:
|
||||
showDialog(
|
||||
showDialog<Null>(
|
||||
context: context,
|
||||
child: new _NotImplementedDialog()
|
||||
);
|
||||
@@ -267,7 +267,7 @@ class StockHomeState extends State<StockHome> {
|
||||
Navigator.pushNamed(context, '/stock/${stock.symbol}');
|
||||
},
|
||||
onShow: (Stock stock) {
|
||||
_scaffoldKey.currentState.showBottomSheet((BuildContext context) => new StockSymbolBottomSheet(stock: stock));
|
||||
_scaffoldKey.currentState.showBottomSheet<Null>((BuildContext context) => new StockSymbolBottomSheet(stock: stock));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class StockSettingsState extends State<StockSettings> {
|
||||
_handleOptimismChanged(false);
|
||||
break;
|
||||
case StockMode.pessimistic:
|
||||
showDialog(
|
||||
showDialog<bool>(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
title: new Text("Change mode?"),
|
||||
@@ -85,7 +85,7 @@ class StockSettingsState extends State<StockSettings> {
|
||||
),
|
||||
]
|
||||
)
|
||||
).then(_handleOptimismChanged);
|
||||
).then<Null>(_handleOptimismChanged);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user