Open tsafundzic opened 1 year ago
Thank you for reporting the issue and providing the sample code. Good issue!
Your responsive value doesn't cover all screen widths. So if the device is between 450 and 800, it returns a null value.
Either provide a default value ResponsiveValue(defaultValue: 450), or set conditions that cover all possible screen widths.
ResponsiveValue<double>(
context,
conditionalValues: [
Condition.equals(name: MOBILE, value: 450),
Condition.between(start: 800, end: 1100, value: 800),
Condition.between(start: 1000, end: 1200, value: 1000),
],
).value
Conditions are set in builder in MaterialApp. Same as yours.
I had the same issue.
You need to set the default value here:
ResponsiveScaledBox(
width: ResponsiveValue<double>(
context,
defaultValue: 450, // default value to avoid _TypeError (type 'Null' is not a subtype of type 'double' in type cast)
conditionalValues: [...],
).value,
child: child
When i met it in the first time, It has crashed my features when i updated to new version of this package, i took a while to found out the reason.
i think the owner should add an assert
or mark defaultValue
required to inform for the developer know.
Thanks
Flutter Channel stable, 3.13.2 Responsive framework 1.1.1
On web and macOS I got error when resizing window:
This is builder in MaterialApp, without it, app works without null exception: