You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/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.
The text was updated successfully, but these errors were encountered:
/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;
tolate 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.The text was updated successfully, but these errors were encountered: