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

Build failing #7

Closed
hipoojan opened this issue Sep 11, 2021 · 2 comments
Closed

Build failing #7

hipoojan opened this issue Sep 11, 2021 · 2 comments

Comments

@hipoojan
Copy link

/opt/hostedtoolcache/flutter/2.5.0-stable/x64/.pub-cache/hosted/pub.dartlang.org/flutter_stories-0.3.0/lib/flutter_stories.dart:174:34: Error: Operator '+' cannot be called on 'int?' because it is potentially null.
setState(() => _currentIdx += 1);
^
/opt/hostedtoolcache/flutter/2.5.0-stable/x64/.pub-cache/hosted/pub.dartlang.org/flutter_stories-0.3.0/lib/flutter_stories.dart:164:8: Context: '_currentIdx' refers to a property so it couldn't be promoted.
See http://dart.dev/go/non-promo-property
int? _currentIdx;
^
/opt/hostedtoolcache/flutter/2.5.0-stable/x64/.pub-cache/hosted/pub.dartlang.org/flutter_stories-0.3.0/lib/flutter_stories.dart:174:34: Error: A value of type 'num' can't be assigned to a variable of type 'int?'.
setState(() => _currentIdx += 1);
^
/opt/hostedtoolcache/flutter/2.5.0-stable/x64/.pub-cache/hosted/pub.dartlang.org/flutter_stories-0.3.0/lib/flutter_stories.dart:189:36: Error: Operator '-' cannot be called on 'int?' because it is potentially null.
setState(() => _currentIdx -= 1);
^
/opt/hostedtoolcache/flutter/2.5.0-stable/x64/.pub-cache/hosted/pub.dartlang.org/flutter_stories-0.3.0/lib/flutter_stories.dart:164:8: Context: '_currentIdx' refers to a property so it couldn't be promoted.
See http://dart.dev/go/non-promo-property
int? _currentIdx;
^
/opt/hostedtoolcache/flutter/2.5.0-stable/x64/.pub-cache/hosted/pub.dartlang.org/flutter_stories-0.3.0/lib/flutter_stories.dart:189:36: Error: A value of type 'num' can't be assigned to a variable of type 'int?'.
setState(() => _currentIdx -= 1);
^

FAILURE: Build failed with an exception.

Flutter version: 2.5.0

I did find a fix, I changed the int? _currentIdx; to late int _currentIdx; as you are clearly initializing the variable in initState method so it won't be null even if the user doesn't provide a startAt as it is initialized to be 0 in the constructor and removed all the unnecessary "!" after _currentIdx just to get rid of the warnings.

@Jagmohanrai
Copy link
Contributor

I have fixed that issue and created a PR you can check it out

@vanelizarov
Copy link
Owner

Fix landed in 0.3.1

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

No branches or pull requests

3 participants