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

What is the error in my code and how do I parse the data from a json successfully?

I am developing a weather app in flutter and encountered an issue where when we type in the city name in the search bar and click on the next icon it displays the weather of that particular place on the screen. But just to make sure that the data is…
Rajesh
  • 91
  • 8
0
votes
1 answer

Unable to fetch data from firebase firestore using flutter

Ive been trying to display images from firestore the code show no error and compiles but not able to display images,i am using web soo only configured for flutter web and rechecked. I am using cloud_firestore: ^3.1.0, and thought of using the new…
ud_
  • 11
  • 2
0
votes
2 answers

what is other solution for "required" in null safety to get uid in firestore?

I'm learning flutter from the older version with the new one. so, I have many times problem with null safety. I have code in database.dart file like this : import 'package:cloud_firestore/cloud_firestore.dart'; class DatabaseService { final…
0
votes
1 answer

Passing arguments in navigator flutter

I am facing a problem in my app after updating to new version of flutter (null safety). i have router and navigator set up as described in code below, when i run the app the router returns error: "type Null is not a subtipe of type ScreenArgs in…
Jan Smitka
  • 109
  • 3
0
votes
0 answers

How to handle futures in init state

Hi I was trying to load a future data from firebase in init state using my model UserModel.fromJson(Map user) but it keep throwing an error: Null is not a sub type of Map I know the future is not loaded right away…
0
votes
1 answer

Dart get class property value dynamically

I have a Class YearlyReportArchive, I want to be able to read the value of a single month dynamically and also add all the months and return the sum. Is there a better solution than what I came up with? import…
Trax
  • 1,445
  • 5
  • 19
  • 39
0
votes
1 answer

The argument type 'void Function()? Function(int)' can't be assigned to the parameter type 'void Function(int?)?' after null safety

I want to migrate my flutter app to null safety and I have this error The argument type 'void Function()? Function(int)' can't be assigned to the parameter type 'void Function(int?)?' in "OnTap: handleItemSelected, _NavigationBarItem( …
0
votes
1 answer

flutter: migrate to null safety an old project

I have this libraries in my project: environment: sdk: ">=2.7.0 <3.0.0" dependencies: after_layout: ^1.1.0 alt_sms_autofill: ^1.0.0 another_flushbar: ^1.10.24 avatar_glow: ^2.0.2 barcode_scan2: ^4.1.4 camera: ^0.9.2+2 …
Cyrus the Great
  • 5,145
  • 5
  • 68
  • 149
0
votes
2 answers

The argument type 'String?' can't be assigned to the parameter type 'String'. -Flutter

This is my my code and null safety is enabled. I am not able to understand why I am facing the mentioned error where I am storing the value for "videoId". Also, what can be another way to store this value for using later as I don't think that its…
0
votes
1 answer

Please how do I set a String variable to null in firestore with flutter?

//I am trying to do this String? userAvaterUrl = null; //so I can do this: FutureBuilder( future: getPicture(), builder: (context, snapshot) { if (snapshot.hasData ||…
Ugocode
  • 235
  • 1
  • 3
  • 10
0
votes
0 answers

How to get initial binding with getx and flutter?

What is wrong with it? The analyzer says there is constant constructor, I do not understand it?? The error The binding class
Ahmed_Saied
  • 59
  • 1
  • 7
0
votes
1 answer

Flutter Dart "unconditionally accessed because the receiver can be 'null'." problem

Here is my flutter code where I try to use FutureBuilder but encounter problems due to the null protection in Dart. class AbcClass extends StatefulWidget { @override _AbcClassState createState() => _AbcClassState(); } class…
edn
  • 1,981
  • 3
  • 26
  • 56
0
votes
2 answers

Group by multiple fields and get max value using Dart and Flutter

I am new to dart, I have a requirement to group by multiple fields and get the minimum value of each student. I don't have an idea on how to implement since I am new in dart. Below is the example of the realtime firebase table…
cris gomez
  • 131
  • 1
  • 15
0
votes
1 answer

Null Safety Migration: How to migrate an App with intl package?

I am using intl: ^0.17.0 in the App that I want to migrate to null safety. All my packages, including intl, support null safety so the dart migrate analysis works without a problem and I can go to the migration assistant link. However when I get…
David L
  • 1,134
  • 7
  • 35
0
votes
1 answer

Closure call with mismatched arguments: function 'LoginScreen.build.

Hello I'm getting this error when I tried to run the code Here is the full error: ======== Exception caught by widgets library ======================================================= The following NoSuchMethodError was thrown building…