Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The following _CastError was thrown building #22

Open
PierreBresson opened this issue Feb 25, 2022 · 2 comments
Open

The following _CastError was thrown building #22

PierreBresson opened this issue Feb 25, 2022 · 2 comments

Comments

@PierreBresson
Copy link

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

@jamesblasco
Copy link
Owner

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

@PierreBresson
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants