Codelessly / ResponsiveFramework

Easily make Flutter apps responsive. Automatically adapt UI to different screen sizes. Responsiveness made simple. Demo: https://gallery.codelessly.com/flutterwebsites/minimal/
https://codelessly.com
MIT License
1.28k stars 150 forks source link

Condition on ResponsiveVisibility requires a value in v1 #157

Closed jsarafajr closed 9 months ago

jsarafajr commented 1 year ago

Since value property is now required on breakpoint condition it forces you to pass it in the ResponsiveVisibility conditions even though it's not used:

ResponsiveVisibility(
  hiddenConditions: [Condition.smallerThan(name: DESKTOP, value: true)],
  child: ...
)

while probably the expected usage would be to not pass it in this case:

hiddenConditions: [Condition.smallerThan(name: DESKTOP)],

Right now you get The named parameter 'value' is required, but there's no corresponding argument. when trying to do so.

rayliverified commented 1 year ago

Thank you for bringing this side effect of the API change to my attention.

It was definitely not my intention to change the ResponsiveVisibility API in this way. This new usage is much more awkward and bad.

Conditions now require a value to support nullability inheritance. Without requiring the value, the library cannot infer the nullability.

I wonder what can be done here? 🥶

rayliverified commented 9 months ago

The issue was a Dart language limitation that did not support generic type nullability. With the latest Flutter v3.19, nullable generic types now flow through correctly and the awkwardness can be removed.

We're back to the original API where a constant condition can be passed without forcibly attaching a value!