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
2 answers

How to avoid getting null data when it is assigned to global variables in flutter?

I've stored user data in shared preferences as users login into the app, the data saved successfully as checked via print in consol, the problem there is as when data is stored in a global variable for later use it gives the null userID. int?…
0
votes
1 answer

What should I do if I want to use a dependency and it doesn't support null safety?

I'm trying to use Geocoder Dependence but it does not don't support null safety. Is there any method to use Geocoder Dependence in the project? Here is the error Launching lib\main.dart on Android SDK built for x86 in debug mode... Running Gradle…
Adeel Nazim
  • 640
  • 6
  • 17
0
votes
1 answer

Can anybody help me regarding this error in Flutter Firebase data access using Snapshot in text showing error?

snapshot.data.documents[][] Widget build(BuildContext context) { return Scaffold( body: StreamBuilder( stream:Firestore.instance.collection('chats/wuQaqmmo64XVBVJ6S6ET/messages') .snapshots() ,builder: (ctx,snapshot)…
0
votes
1 answer

Converting to GetX raises issues

I am converting my flutter app to use GetX rather than provider and during the conversion I am getting some errors that I don't know how to correct. First error: In my data model, AgentsModel, I am getting an error in the method…
LostTexan
  • 431
  • 5
  • 18
0
votes
2 answers

How do I access the value of a given key in a nested Map in Dart?

I am new in Dart and I have been trying to access the value of "farm_size" key in the following piece of code but unsuccessful. I can access up to "farms" like this print(myData1[0]["farms"]); But not any further. Any help will be appreciated.…
willy
  • 101
  • 1
  • 9
0
votes
2 answers

Flutter textfield is not updating another variable

I have the following widget. import 'package:flutter/material.dart'; class AddTaskScreen extends StatelessWidget { @override Widget build(BuildContext context) { String? newTaskTitle; return Container( color: Color(0xFF757575), …
Pranta
  • 2,928
  • 7
  • 24
  • 37
0
votes
2 answers

Flutter DateTimePicker size is too small | Resize Flutter DateTimePicker size

I'm trying to maximize the DatePicker size due to user feedback (too small on other devices). I've tried adding a builder but it didn't make any difference. The following is my current code: _datePicker() { return showDatePicker( context:…
0
votes
2 answers

How to pass a value bool? in a switch in flutter

I am making a form with switches in Flutter and I would like to save the value of it, but Flutter doesn't want a value bool? so I don't know how to get my value. Here is my code : Switch( value: _editedProduct.myswitchvalue, //line that causes…
0
votes
1 answer

Getting This Error on Run Time "Null check operator used on a null value"

I am building a Dictionary app using using api owlbot. My code Run fines shows no error. But after the run time i am getting error ════════ Exception caught by widgets ═══════════════════════════════════════════ Null check operator…
0
votes
1 answer

Alternative of package PathProviderEx in flutter

Tried every thing, when trying to access the root directory of the app it throws this exceptions. Is there any way to get the root of device on flutter2 with null safety ?
Wali Khan
  • 586
  • 1
  • 5
  • 13
0
votes
1 answer

Getting null safety errors when tried to get autocomplete location of places in Flutter and display details on tapped place

I tried to migrate the no null safety code to null safety and I ended up with errors. I want to get autocomplete location of places in Flutter and display details on the tapped place. Screenshots of errors: The code: main.dart import…
0
votes
1 answer

How to list all local mp3 files on flutter2(null safety)?

The code should be working on flutter2, with android and ios(if possible)
Wali Khan
  • 586
  • 1
  • 5
  • 13
0
votes
2 answers

Difference between Object, Dynamic and Var in Dart?

There is a discussion about dynamic and var before null-safety. Then what's the Object? between each of them? Is Object? == dynamic? How about var? and dynamic?? Any difference between dynamic? and dynamic? I see the official document about…
Tokenyet
  • 4,063
  • 2
  • 27
  • 43
0
votes
1 answer

Correcting Null Safety issue with StreamBuilder in Flutter app

I have an null safety issue with my StreamBuilder in my flutter app. On the open bracket "{" of the builder: property I am getting this error The body might complete normally, causing 'null' to be returned, but the return type is a potentially…
LostTexan
  • 431
  • 5
  • 18
0
votes
1 answer

(Flutter) Upgrading To NullSafety

Hi, I'm trying to upgrade an old code to null safety, but since I'm just starting to learn null safety, I'm encountering errors and I couldn't figure out why, I would be glad if you could help. I've tried a few things, but I'm leaving it in its…
Burak
  • 3
  • 1