-
-
Notifications
You must be signed in to change notification settings - Fork 21
flutter:master FlutterError (Scrollable.of() was called with a context that does not contain a Scrollable widget. #12
Description
The upcoming Flutter change from of to maybeOf might break gap: ^2.0.0, because of its usage of Scrollable.of.
Issue description
When using Gap(...) outside of a Scrollable container the issue will show up as:
Exception has occurred.
FlutterError (Scrollable.of() was called with a context that does not contain a Scrollable widget.
No Scrollable widget ancestor could be found starting from the context that was passed to Scrollable.of(). This can happen because you are using a widget that looks for a Scrollable ancestor, but no such ancestor exists.
The context used was:
Gap(dirty))
A flutter version without the change will run without error.
What will/has change(d)
PR Add maybeOf for all the cases where of returns nullable has been merged to flutter:master and will most probably land in a beta and then stable release.
A description of the Flutter changes and a migration guide is available at:
Migrate of to non-nullable return values, and add maybeOf
Current Status 11/16/2022
gap: ^2.0.0 on current flutter:stable channel [Not reproduceable]
% flutter channel stable
% flutter upgrade
% flutter --version
Flutter 3.3.8 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 52b3dc25f6 (7 days ago) • 2022-11-09 12:09:26 +0800
Engine • revision 857bd6b74c
Tools • Dart 2.18.4 • DevTools 2.15.0gap: ^2.0.0 on flutter:beta channel [Not reproduceable]
% flutter channel beta
% flutter upgrade
% flutter --version
Flutter 3.4.0-34.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 71520442d4 (6 weeks ago) • 2022-10-05 16:38:28 -0500
Engine • revision db0cbb2145
Tools • Dart 2.19.0 (build 2.19.0-255.2.beta) • DevTools 2.18.0gap: ^2.0.0 on flutter:master channel [Reproduceable]
% flutter channel master
% flutter upgrade
% flutter --version
Flutter 3.6.0-3.0.pre.55 • channel master • https://github.com/flutter/flutter.git
Framework • revision 484e09ef79 (35 minutes ago) • 2022-11-16 05:18:10 -0500
Engine • revision 0241f18cbe
Tools • Dart 2.19.0 (build 2.19.0-406.0.dev) • DevTools 2.19.0
Quick fix for Flutter master / upcoming beta? channel users
I have made a change in my fork at fix_scrollable_of_issue_with_flutter_master
To use this fix, make the following change in your pubspec.yaml
# gap: ^2.0.0
gap:
git:
url: https://github.com/incima/gap.git
ref: 307be282e99e6f27c2899cd5c81d724b267f18f4 @letsar Thank you for this convenient package. This is just meant as a heads up.