layout
layout copied to clipboard
The following _CastError was thrown building
Environment
ios
Version:
layout: ^1.0.2
Description
I'm having a red error screen when wrapping Layout around MaterialApp and using context.layout.breakpoint
Here is the error :
The following _CastError was thrown building FwpApp(dirty, state: _FwpAppState#4edf4):
Null check operator used on a null value
...
The relevant error-causing widget was:
FwpApp FwpApp:file:///Users/pierrebresson/Documents/Code/fwp/lib/setup_app.dart:53:22
When the exception was thrown, this was the stack:
#0 Layout.of (package:layout/src/layout.dart:55:68)
#1 LayoutBuildContext.layout (package:layout/src/layout.dart:163:35)
#2 _FwpAppState.build (package:fwp/app.dart:129:18)
Which I believe is caused by the ! operator inside 'src/layout.dart' line 54 :
static LayoutData of(BuildContext context) => context
.dependOnInheritedWidgetOfExactType<_LayoutInheritedWidget>()!
Steps to reproduce
You can reproduce the issue on this repo. You will get the error if you add Layout and then simply try to use context.layout.breakpoint
I think you haven't added the Layout widget anywhere in your app no?
https://github.com/PierreBresson/flutter-wordpress-podcast/search?q=Layout&type=code
Yeap, I was testing it locally, here is the example commited : https://github.com/PierreBresson/flutter-wordpress-podcast/blob/22b53e2788dbf25cd0c9ae454854e641e6deb529/lib/app.dart#L135