Questions tagged [dart-null-safety]

Tag for questions regarding Dart code involving non-nullable types. This should only be used in combination with the Dart tag.

With the announcement of null safety, there are two types of Dart code:

  • Code with only nullable types.
  • Code with null safety enabled → with non-nullable types.

The tag covers questions involving the latter. Question with this tag should be subset of .

1185 questions
0
votes
0 answers

"receiver can be null" when it can't?

I just finished my nullsafe migration. I'm finding that wrapping code with a null check only sometimes removes the need for the nullcheck ! operator? E.g., class MyClass { double divideBy4(double numerator) { return numerator / 4; } …
buttonsrtoys
  • 2,359
  • 3
  • 32
  • 52
0
votes
1 answer

Dart null safety breaks animated builder

I am getting this error in Animated Builder after I enable dart null safety in my flutter because one of my plugin needs it. return AnimatedBuilder( //animation is done here animation:_pageController, builder:…
BestOFBest
  • 43
  • 7
0
votes
1 answer

Add color transitions

I'm trying to make a color animate a color from green to amber to red. Before upgrading to null-safety, the following code was working fine, but now it's throwing errors... TweenSequence([ TweenSequenceItem(weight: 0.5, tween:…
Jessica
  • 9,379
  • 14
  • 65
  • 136
0
votes
0 answers

Flutter 2.0.4 (stable): Null check operator used on a null value ERROR

I recently migrated my app to Flutter 2.0 which contains Null safety. After successful migration, when I run the app, I get the following error The following _CastError was thrown building ContactListWidget(dirty, dependencies: [MediaQuery,…
shangod
  • 517
  • 1
  • 4
  • 10
0
votes
0 answers

NoSuchMethod Errors Inside Repository & Data Sources Classes While Using FlutterSecureStorage Package

I am trying to persist the user authentication state of an already working auth system using flutter_bloc and Nodejs, by storing my successfully retrieved and generated JWTs. I have chosen flutter_secure_storage (FSS), for brevity as my key-value…
Nzadibe
  • 598
  • 2
  • 11
  • 28
0
votes
1 answer

Flutter null-safety migration stuck on "named parameter isn't defined" errors

I am trying to migrate one of my project to null-safety following this guide and this video, but I'm stuck somewhere between upgrading my dependencies and seeing the migration suggestions in the web interface. I managed to upgrade my project from…
Sebastien
  • 3,583
  • 4
  • 43
  • 82
0
votes
2 answers

'UserModel? Function(User)' cant be assigned to the parameter type 'UserModel Function(User?)' because 'UserModel?' is nullable and 'UserModel' isn't

#I've been following a youtube project for twitter clone and I get error when putting _userFromFirebaseUser in map();# ##I get error at time 13:29, here is the link. https://www.youtube.com/watch?v=YI7avcWI3aQ&t=919s ## ##The error that I received…
0
votes
1 answer

Flutter keyboard not showing up on both emulator and real devices>

What I mean is that the keyboard did show up for milliseconds and it then disappeared immediately, this is inside a Modal Bottom Sheet, but I don't think it's the problem of the Sheet. Container( height: 50, width: double.infinity, padding:…
0
votes
2 answers

Flutter: Unable to migrate to null safety

I am following this guide to migrate my project to null safety: https://dart.dev/null-safety/migration-guide But I am facing this issue with the dart migrate command : FileSystemException(path=C:\Program Files\Dart\dart-sdk\version; message=Cannot…
Himanshu Sharma
  • 984
  • 2
  • 15
  • 40
0
votes
0 answers

Failed to add user: [cloud_firestore/unknown] Expected a value of type '((Object) => Object)?', but got one of type '(Object?) => dynamic

I'm trying to user firestore on flutter null safety version but I have this problem when getting data or write data Failed to add user: [cloud_firestore/unknown] Expected a value of type '((Object) => Object)?', but got one of type '(Object?) =>…
0
votes
1 answer

Failing to build my project due to Null safety issues in Dart

I have been away from Flutter and Dart for some month now but when I saw that Flutter 2 was released I decided to update one of my Flutter projects. Super cool evertything and I just love Flutter and Dart. Now I have run in to a null safety…
Gunnar Eketrapp
  • 2,009
  • 1
  • 19
  • 33
0
votes
0 answers

Implementing classes with null safety enabled causes compilation error

A bunch of the classes I implemented (for mocking purposes) without null safety have compilation errors now. Take this example: class MockProvider extends Mock implements Provider{} This throws the error: 'Object.toString' ('String…
Wilson Wilson
  • 3,296
  • 18
  • 50
0
votes
1 answer

Dependency conflict

I am little bit confused. When I added easy_localization dependency and run flutter pub get then I give following message: Because easy_localization >=2.1.0+1 <2.3.4-nullsafety depends on flutter_localizations any from sdk which depends on path…
jirkapenzes
  • 93
  • 1
  • 12
0
votes
1 answer

An expression whose value can be 'null' must be null-checked before it can be dereferenced

I am using Dart with null-safity mode. I have porblem in next code. List _jobList = []; // ... if(_jobList.isNotEmpty) { for(var job in _jobList) { if(job.cmd_args != null) { …
Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
0
votes
2 answers

Dart Null Safety in a callback function with named params

The code below fails when compiling with Null Safety the following error: The parameter namedParam can't have a value of null because of its type, and no non-null default value is provided. void main() { Foo(callbackWithNamedParam: ({namedParam})…
tonymontana
  • 5,728
  • 4
  • 34
  • 53