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

null safety on scrollable_positioned_list-0.3.6 #468

Open
oopses opened this issue Apr 28, 2023 · 3 comments · May be fixed by #484
Open

null safety on scrollable_positioned_list-0.3.6 #468

oopses opened this issue Apr 28, 2023 · 3 comments · May be fixed by #484

Comments

@oopses
Copy link

oopses commented Apr 28, 2023

Flutter version: 3.3.1
scrollable_positioned_list-0.3.6

0.3.6 An error was reported during compilation:

/usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/scrollable_positioned_list-0.3.6/lib/src/scrollable_positioned_list.dart:278:61: Error: Method 'readState' cannot be called on 'PageStorageBucket?' because it is potentially null.
 - 'PageStorageBucket' is from 'package:flutter/src/widgets/page_storage.dart' ('/usr/local/flutter/packages/flutter/lib/src/widgets/page_storage.dart').
[        ] Try calling using ?. instead.
[        ]     ItemPosition? initialPosition = PageStorage.of(context).readState(context);
[        ]                                                             ^^^^^^^^^
[   +1 ms] /usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/scrollable_positioned_list-0.3.6/lib/src/scrollable_positioned_list.dart:577:31: Error: Method 'writeState' cannot be called on 'PageStorageBucket?' because it is potentially null.
[        ]  - 'PageStorageBucket' is from 'package:flutter/src/widgets/page_storage.dart' ('/usr/local/flutter/packages/flutter/lib/src/widgets/page_storage.dart').
[        ] Try calling using ?. instead.
[        ]       PageStorage.of(context).writeState(
[        ]                               ^^^^^^^^^^
[   +3 ms] Target kernel_snapshot failed: Exception

Currently fix the version to 0.3.5 normally

@247software-vaibhav-joshi
Copy link

247software-vaibhav-joshi commented Apr 28, 2023

We are having same error while building the application, Guess this issue occurred due to new release.
Resolved it by using a fixed version like scrollable_positioned_list: 0.3.2. remove the ^ from scrollable_positioned_list: 0.3.2

@XutongGithub
Copy link

we have the same error

../../flutter/.pub-cache/hosted/pub.flutter-io.cn/scrollable_positioned_list-0.3.6/lib/src/scrollable_positioned_list.dart:577:31: Error: Method 'writeState' cannot be called on 'PageStorageBucket?' because it is potentially null.

  • 'PageStorageBucket' is from 'package:flutter/src/widgets/page_storage.dart' ('../../../flutter/packages/flutter/lib/src/widgets/page_storage.dart').
    Try calling using ?. instead.
    PageStorage.of(context).writeState(
    ^^^^^^^^^^

FAILURE: Build failed with an exception.

@ezamagni
Copy link

PageStorage.of returns a nullable PageStorageBucket? in flutter 3.3.x
This has changed in flutter 3.7.x where we have the following alternative methods:

  • PageStorageBucket of(BuildContext context)
  • PageStorageBucket? maybeOf(BuildContext context)

So, scrollable_positioned_list is only compatible with Flutter 3.7.x and newer, starting from version 0.3.6
If you're still on flutter 3.3.x you should pin to the latest compatible version in your pubspec.yaml like so:

scrollable_positioned_list: 0.3.5

@mx1up mx1up linked a pull request Jul 29, 2023 that will close this issue
4 tasks
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

Successfully merging a pull request may close this issue.

4 participants