Add maybeOf for all the cases where of returns nullable. (#114120)

This commit is contained in:
Greg Spencer
2022-10-31 16:09:09 -07:00
committed by GitHub
parent b20b7d995b
commit 37b72342b0
73 changed files with 836 additions and 308 deletions

View File

@@ -34,7 +34,7 @@ class FromSectionExample extends StatelessWidget {
child: Form(
autovalidateMode: AutovalidateMode.always,
onChanged: () {
Form.of(primaryFocus!.context!)?.save();
Form.maybeOf(primaryFocus!.context!)?.save();
},
child: CupertinoFormSection.insetGrouped(
header: const Text('SECTION 1'),

View File

@@ -38,7 +38,7 @@ class MyStatelessWidget extends StatelessWidget {
// The Builder widget is used to have a different BuildContext to access
// closest DefaultTabController.
child: Builder(builder: (BuildContext context) {
final TabController tabController = DefaultTabController.of(context)!;
final TabController tabController = DefaultTabController.of(context);
tabController.addListener(() {
if (!tabController.indexIsChanging) {
// Your code goes here.

View File

@@ -44,7 +44,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
child: Form(
autovalidateMode: AutovalidateMode.always,
onChanged: () {
Form.of(primaryFocus!.context!)!.save();
Form.of(primaryFocus!.context!).save();
},
child: Wrap(
children: List<Widget>.generate(5, (int index) {