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
2
votes
1 answer

flutter_inner_drawer error: type 'List' is not a subtype of type 'List' in type cast

Using flutter_inner_drawer: ^1.0.0+1 I got a error thats is type 'List' is not a subtype of type 'List' in type cast my code: final GlobalKey _innerDrawerKey = GlobalKey(); InnerDrawer( …
Fuad Mostafij
  • 47
  • 2
  • 8
2
votes
0 answers

Duplicate letters in wordle flutter dart

The program I created compares the letters of the target word and the guessed word. An example: the target word is "compulsory" and the guessed word is "submission". The output should be "-O-O--X-O-". "X" meaning the letter in the guessed word is…
umutcan bağdu
  • 158
  • 1
  • 1
  • 9
2
votes
1 answer

A value of type 'Object?' can't be assigned to a variable of type 'SigninCharacter'

I'm making a radio button then i face this error.//A value of type 'Object?' can't be assigned to a variable of type 'SigninCharacter'. Try changing the type of the variable, or casting the right-hand type to 'SigninCharacter'.\ enum SigninCharacter…
2
votes
1 answer

Exception has occurred._TypeError(type '(dynamic)=>Patient' is not a subtype of type '(String, dynamic)= MapEntry' of 'transform')

When I'm trying to get data from API flutter to give this error. Exception has occurred._TypeError(type '(dynamic)=>Patient' is not a subtype of type '(String, dynamic)= MapEntry' of 'transform') JSON data { "pageIndex": 0, …
2
votes
1 answer

i get errors when I fetch my data from an API using http.get()

I am facing this issue in my code and I am not able to solve it. I`m trying to fetch data through an API, and I get these errors in my IDE. [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type…
2
votes
2 answers

Flutter Error: StackOverflowError was thrown building Consumer(dirty, dependencies: [_InheritedProviderScope])

i'm trying to include live location tracking into my app using the following packages: google_maps_flutter 2.1.2 --> https://pub.dev/packages/google_maps_flutter/install location 4.3.0 --> https://pub.dev/packages/location provider 6.0.2 -->…
2
votes
2 answers

flutter pub run build_runner build not working

when running flutter pub run build_runner build I get this error. Failed to build build_runner:build_runner: ../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:258:50:…
2
votes
1 answer

The property 'latitude' can't be unconditionally accessed because the receiver can be 'null'. Try making the access conditional (using '?.')

I am facing a null safety issue in Text( "Latitude: " + currentPosition.latitude.toString(), ) this line. i dont know how to make currentPosition.latitude not null help me with this guys. It gives me this The property 'latitude' can't be…
2
votes
2 answers

Flutter_form_builder errors

I'm trying to use flutter_form_builder: ^7.1.0 with form_builder_validators to create a form, but a getting undefined errors at onChanged: _onChanged, and validator: FormBuilderValidators.compose. I tried following the example at…
markhorrocks
  • 1,199
  • 19
  • 82
  • 151
2
votes
1 answer

firebase_database - error after flutter migration - DataSnapshot syntax

I used this code bevor migration void initState() { DatabaseReference db; db = FirebaseDatabase.instance.ref().child("likes"); db.once().then((DataSnapshot snapshot) { Map values = snapshot.value; …
Bernhard
  • 188
  • 10
2
votes
1 answer

why is the null-check of an outer variable isn't enough in dart?

Why does the below code give an error? Function? fob; void someMethod() { if(fob != null) { fob(); } } Why is this null-check not enough and fob(); here gives an error? What could be happening between the if check and the call to…
Aegletes
  • 460
  • 2
  • 6
  • 17
2
votes
1 answer

Flutter : Unhandled Exception: Null check operator used on a null value

I am trying to navigate to a new screen by pressing the "Process Order" Button but I keep getting the error [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value. I am not sure where exactly the error is…
supremo
  • 133
  • 1
  • 3
  • 10
2
votes
1 answer

A value of type 'StreamSink' can't be returned from the function 'assessmentSink'

class AssessmentBloc { late AssessmentRepository _genRepository; late StreamController assessmentController; late StreamController submitAssessmentController; StreamSink> get assessmentSink =>…
FatahZull
  • 43
  • 7
2
votes
2 answers

Why can we not change the variable value if initialises at the time of declaration?

I am learning dart and this behavior of dart is annoying me var a=10; a="John"; //it generates an error, because a has integer data-type and we can't assign //string or the value of any other data type because we have assigned an …
Muhammad Afzal
  • 118
  • 1
  • 9
2
votes
2 answers

I get multiple errors from an old version code because of Null-Safety

Im trying to revize an old basic shopping app with firebase but its old version code and couldnt get the null safety exactly. Could anyone help me. Here i get "non-nullable instance field '_selectedParam' must be initialized" also for 'database' i…
Sena
  • 37
  • 5