Flutter upgrade nullsafety after `dart migrate`

1 firstWhere

void method(){

List rs
//before
rs.firstWhere((element) => false, orElse: () => ,);

//should change
import 'package:collection/collection.dart';
rs.firstWhereOrNull((element) =>) ?? '';
}

2 provider

//if use provider in StatefulWidget, most use ChangeNotifierProvider.value()

//before
NotifierModel? model;

//should change
late NotifierModel model;

@override
void initState() {
    model = NotifierModel();
    super.initState();
}

@override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider.value(value: model, child:...);
}


你可能感兴趣的:(Flutter upgrade nullsafety after `dart migrate`)