Prefer void to null (#22977)
* Future<void> main * Future<void>.delayed * prefer_void_to_Null * address review comments
This commit is contained in:
committed by
GitHub
parent
5efe095895
commit
0fb84e96c7
@@ -351,7 +351,7 @@ class _DemoBottomAppBar extends StatelessWidget {
|
||||
IconButton(
|
||||
icon: const Icon(Icons.menu),
|
||||
onPressed: () {
|
||||
showModalBottomSheet<Null>(
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const _DemoDrawer(),
|
||||
);
|
||||
|
||||
@@ -64,7 +64,7 @@ class _DateTimePicker extends StatelessWidget {
|
||||
final ValueChanged<DateTime> selectDate;
|
||||
final ValueChanged<TimeOfDay> selectTime;
|
||||
|
||||
Future<Null> _selectDate(BuildContext context) async {
|
||||
Future<void> _selectDate(BuildContext context) async {
|
||||
final DateTime picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDate,
|
||||
@@ -75,7 +75,7 @@ class _DateTimePicker extends StatelessWidget {
|
||||
selectDate(picked);
|
||||
}
|
||||
|
||||
Future<Null> _selectTime(BuildContext context) async {
|
||||
Future<void> _selectTime(BuildContext context) async {
|
||||
final TimeOfDay picked = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: selectedTime
|
||||
|
||||
@@ -180,7 +180,7 @@ class DialogDemoState extends State<DialogDemo> {
|
||||
context: context,
|
||||
initialTime: _selectedTime
|
||||
)
|
||||
.then<Null>((TimeOfDay value) {
|
||||
.then<void>((TimeOfDay value) {
|
||||
if (value != null && value != _selectedTime) {
|
||||
_selectedTime = value;
|
||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||
|
||||
@@ -49,7 +49,7 @@ class DateTimeItem extends StatelessWidget {
|
||||
firstDate: date.subtract(const Duration(days: 30)),
|
||||
lastDate: date.add(const Duration(days: 30))
|
||||
)
|
||||
.then<Null>((DateTime value) {
|
||||
.then<void>((DateTime value) {
|
||||
if (value != null)
|
||||
onChanged(DateTime(value.year, value.month, value.day, time.hour, time.minute));
|
||||
});
|
||||
@@ -76,7 +76,7 @@ class DateTimeItem extends StatelessWidget {
|
||||
context: context,
|
||||
initialTime: time
|
||||
)
|
||||
.then<Null>((TimeOfDay value) {
|
||||
.then<void>((TimeOfDay value) {
|
||||
if (value != null)
|
||||
onChanged(DateTime(date.year, date.month, date.day, value.hour, value.minute));
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ class ListDemo extends StatefulWidget {
|
||||
class _ListDemoState extends State<ListDemo> {
|
||||
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
PersistentBottomSheetController<Null> _bottomSheet;
|
||||
PersistentBottomSheetController<void> _bottomSheet;
|
||||
_MaterialListType _itemType = _MaterialListType.threeLine;
|
||||
bool _dense = false;
|
||||
bool _showAvatars = true;
|
||||
@@ -51,7 +51,7 @@ class _ListDemoState extends State<ListDemo> {
|
||||
}
|
||||
|
||||
void _showConfigurationSheet() {
|
||||
final PersistentBottomSheetController<Null> bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) {
|
||||
final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState.showBottomSheet<void>((BuildContext bottomSheetContext) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Colors.black26)),
|
||||
|
||||
@@ -26,10 +26,10 @@ class OverscrollDemoState extends State<OverscrollDemo> {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'
|
||||
];
|
||||
|
||||
Future<Null> _handleRefresh() {
|
||||
final Completer<Null> completer = Completer<Null>();
|
||||
Timer(const Duration(seconds: 3), () { completer.complete(null); });
|
||||
return completer.future.then<Null>((_) {
|
||||
Future<void> _handleRefresh() {
|
||||
final Completer<void> completer = Completer<void>();
|
||||
Timer(const Duration(seconds: 3), () { completer.complete(); });
|
||||
return completer.future.then<void>((_) {
|
||||
_scaffoldKey.currentState?.showSnackBar(SnackBar(
|
||||
content: const Text('Refresh complete'),
|
||||
action: SnackBarAction(
|
||||
|
||||
@@ -28,7 +28,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
setState(() { // disable the button
|
||||
_showBottomSheetCallback = null;
|
||||
});
|
||||
_scaffoldKey.currentState.showBottomSheet<Null>((BuildContext context) {
|
||||
_scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) {
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
@@ -39,7 +39,7 @@ class _ListItem {
|
||||
class _ListDemoState extends State<ReorderableListDemo> {
|
||||
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
PersistentBottomSheetController<Null> _bottomSheet;
|
||||
PersistentBottomSheetController<void> _bottomSheet;
|
||||
_ReorderableListType _itemType = _ReorderableListType.threeLine;
|
||||
bool _reverseSort = false;
|
||||
final List<_ListItem> _items = <String>[
|
||||
@@ -58,7 +58,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
||||
|
||||
void _showConfigurationSheet() {
|
||||
setState(() {
|
||||
_bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) {
|
||||
_bottomSheet = scaffoldKey.currentState.showBottomSheet<void>((BuildContext bottomSheetContext) {
|
||||
return DecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Colors.black26)),
|
||||
|
||||
@@ -69,7 +69,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
||||
}
|
||||
|
||||
void _showExplanatoryText() {
|
||||
_scaffoldKey.currentState.showBottomSheet<Null>((BuildContext context) {
|
||||
_scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Theme.of(context).dividerColor))
|
||||
|
||||
@@ -362,7 +362,7 @@ class _ShrineHomeState extends State<ShrineHome> {
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(debugLabel: 'Shrine Home');
|
||||
static final _ShrineGridDelegate gridDelegate = _ShrineGridDelegate();
|
||||
|
||||
Future<Null> _showOrderPage(Product product) async {
|
||||
Future<void> _showOrderPage(Product product) async {
|
||||
final Order order = _shoppingCart[product] ?? Order(product: product);
|
||||
final Order completedOrder = await Navigator.push(context, ShrineOrderRoute(
|
||||
order: order,
|
||||
|
||||
@@ -66,7 +66,7 @@ class VideoCard extends StatelessWidget {
|
||||
pageBuilder: fullScreenRoutePageBuilder,
|
||||
);
|
||||
|
||||
route.completed.then((void result) {
|
||||
route.completed.then((void value) {
|
||||
controller.setVolume(0.0);
|
||||
});
|
||||
|
||||
@@ -272,7 +272,7 @@ class ConnectivityOverlay extends StatefulWidget {
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final Completer<Null> connectedCompleter;
|
||||
final Completer<void> connectedCompleter;
|
||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
|
||||
@override
|
||||
@@ -362,14 +362,14 @@ class _VideoDemoState extends State<VideoDemo>
|
||||
);
|
||||
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final Completer<Null> connectedCompleter = Completer<Null>();
|
||||
final Completer<void> connectedCompleter = Completer<void>();
|
||||
bool isSupported = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
Future<Null> initController(VideoPlayerController controller) async {
|
||||
Future<void> initController(VideoPlayerController controller) async {
|
||||
controller.setLooping(true);
|
||||
controller.setVolume(0.0);
|
||||
controller.play();
|
||||
|
||||
@@ -138,7 +138,7 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then<Null>((String code) {
|
||||
getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then<void>((String code) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_exampleCode = code ?? 'Example code not found';
|
||||
|
||||
@@ -17,7 +17,7 @@ Future<String> getExampleCode(String tag, AssetBundle bundle) async {
|
||||
return _exampleCode[tag];
|
||||
}
|
||||
|
||||
Future<Null> _parseExampleCode(AssetBundle bundle) async {
|
||||
Future<void> _parseExampleCode(AssetBundle bundle) async {
|
||||
final String code = await bundle.loadString('lib/gallery/example_code.dart') ??
|
||||
'// lib/gallery/example_code.dart not found\n';
|
||||
_exampleCode = <String, String>{};
|
||||
|
||||
Reference in New Issue
Block a user