Add maybeOf for all the cases where of returns nullable. (#114120)
This commit is contained in:
@@ -210,8 +210,8 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
builder: (BuildContext context) {
|
||||
return CollapsibleBody(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
onSave: () { Form.of(context)!.save(); close(); },
|
||||
onCancel: () { Form.of(context)!.reset(); close(); },
|
||||
onSave: () { Form.of(context).save(); close(); },
|
||||
onCancel: () { Form.of(context).reset(); close(); },
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: TextFormField(
|
||||
@@ -244,8 +244,8 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return CollapsibleBody(
|
||||
onSave: () { Form.of(context)!.save(); close(); },
|
||||
onCancel: () { Form.of(context)!.reset(); close(); },
|
||||
onSave: () { Form.of(context).save(); close(); },
|
||||
onCancel: () { Form.of(context).reset(); close(); },
|
||||
child: FormField<Location>(
|
||||
initialValue: item.value,
|
||||
onSaved: (Location? result) { item.value = result; },
|
||||
@@ -298,8 +298,8 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return CollapsibleBody(
|
||||
onSave: () { Form.of(context)!.save(); close(); },
|
||||
onCancel: () { Form.of(context)!.reset(); close(); },
|
||||
onSave: () { Form.of(context).save(); close(); },
|
||||
onCancel: () { Form.of(context).reset(); close(); },
|
||||
child: FormField<double>(
|
||||
initialValue: item.value,
|
||||
onSaved: (double? value) { item.value = value; },
|
||||
|
||||
@@ -12,7 +12,7 @@ class _PageSelector extends StatelessWidget {
|
||||
final List<Icon>? icons;
|
||||
|
||||
void _handleArrowButtonPress(BuildContext context, int delta) {
|
||||
final TabController controller = DefaultTabController.of(context)!;
|
||||
final TabController controller = DefaultTabController.of(context);
|
||||
if (!controller.indexIsChanging) {
|
||||
controller.animateTo((controller.index + delta).clamp(0, icons!.length - 1));
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class _PageSelector extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TabController? controller = DefaultTabController.of(context);
|
||||
final TabController? controller = DefaultTabController.maybeOf(context);
|
||||
final Color color = Theme.of(context).colorScheme.secondary;
|
||||
return SafeArea(
|
||||
top: false,
|
||||
|
||||
@@ -63,7 +63,7 @@ class TabbedComponentDemoScaffold extends StatefulWidget {
|
||||
|
||||
class _TabbedComponentDemoScaffoldState extends State<TabbedComponentDemoScaffold> {
|
||||
void _showExampleCode(BuildContext context) {
|
||||
final String? tag = widget.demos![DefaultTabController.of(context)!.index].exampleCodeTag;
|
||||
final String? tag = widget.demos![DefaultTabController.of(context).index].exampleCodeTag;
|
||||
if (tag != null) {
|
||||
Navigator.push(context, MaterialPageRoute<FullScreenCodeDialog>(
|
||||
builder: (BuildContext context) => FullScreenCodeDialog(exampleCodeTag: tag)
|
||||
@@ -72,7 +72,7 @@ class _TabbedComponentDemoScaffoldState extends State<TabbedComponentDemoScaffol
|
||||
}
|
||||
|
||||
Future<void> _showApiDocumentation(BuildContext context) async {
|
||||
final String? url = widget.demos![DefaultTabController.of(context)!.index].documentationUrl;
|
||||
final String? url = widget.demos![DefaultTabController.of(context).index].documentationUrl;
|
||||
if (url == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM
|
||||
return FloatingActionButton(
|
||||
child: const Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
_play(_allDemos[DefaultTabController.of(context)!.index]);
|
||||
_play(_allDemos[DefaultTabController.of(context).index]);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@@ -172,8 +172,8 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||
markers[MarkerType.topLeft] = box!.localToGlobal(Offset.zero);
|
||||
final Size size = box.size;
|
||||
markers[MarkerType.bottomRight] = box.localToGlobal(Offset(size.width, size.height));
|
||||
final ScrollableState? scrollable = Scrollable.of(target.currentContext!);
|
||||
markersScrollOffset = scrollable!.position.pixels;
|
||||
final ScrollableState scrollable = Scrollable.of(target.currentContext!);
|
||||
markersScrollOffset = scrollable.position.pixels;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user