Skip to content

The following _CastError was thrown building #22

Open
@PierreBresson

Description

@PierreBresson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions