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

null safety on widget parameter

Before null-safety, I can pass widget, if check it is null, will show other widget. On null-safety environment, is there a way if I didn't pass widget image or note? class Message extends StatelessWidget { const Message({ Key key, …
FeelRightz
  • 2,777
  • 2
  • 38
  • 73
-1
votes
1 answer

Flutter: Issue while converting json to model using json_serializable

Suppose there are two models User and City @JsonSerializable() class User { int id; String name; City? city; } @JsonSerializable() class City { int id; String name; } Now suppose during API call, we've got a user model but in the…
-1
votes
2 answers

Lazy loading with Dart null-safety

I am trying to migrate some code to Dart 2.12 with null safety enabled but having an issue finding a good way to migrate methods with lazy loaded/cached values. Dart 2.12 will not compile the following code unless I change the return type of…
Seb T
  • 795
  • 8
  • 16
-1
votes
1 answer

Check weather String is null in dart (nullsafety)

How to check weather a text is null after null-safety update. here my previous code if (k.text != null) { print('not null'); } else { print('null'); } How to perform same operation after null-safety
Alok Kumar
  • 397
  • 1
  • 4
  • 15
-1
votes
1 answer

Null safety and checking for `Null`

this piece of code static fromJson(Map j) { return _TheCountry( name: j["Name"]??"", dialCode: j["DialCode"]??"", iso2Code: j["Iso2"]??"", englishName: j["EnglishName"]??"", iso3Code:…
Yadu
  • 2,979
  • 2
  • 12
  • 27
-1
votes
1 answer

Flutter Null Safety

I have a project I did before null safety was introduced, now my code has a lot of errors and I want to downgrade my flutter and dart to before null safety. How can I do that?
-2
votes
1 answer

Class 'List<_JsonQueryDocumentSnapshot>' has no instance getter 'lenght'. Receiver: Instance(length:3) of '_GrowableList' Tried calling: lenght

home page class i am new to flutter and tying to made a ticket services application. now i am getting this error. Exception caught by widgets library Class 'List<_JsonQueryDocumentSnapshot>' has no instance getter 'lenght'. Receiver:…
Safiullah
  • 5
  • 1
-2
votes
1 answer

how can i solve this problem of dart null safety

this the screenshot of the error that i found
-2
votes
1 answer

confused about the null safety dart

The argument type 'int?' can't be assigned to the parameter type 'num'. when using darts with 'null safety', this code gets an error but when I use the version of darts without null safety the test runs successfully (without error). My question is…
-2
votes
1 answer

type 'Null' is not a subtype of type 'Map' in type cast

Map data={}; Widget build(BuildContext context) { data=ModalRoute.of(context)?.settings.arguments as Map;
-2
votes
1 answer

The method 'map' can't be unconditionally invoked because the receiver can be 'null'

enter image description here there is error with the map even when i add .toList() to the map
alshaikh99
  • 21
  • 2
-2
votes
3 answers

How do i convert this complex json to dart model class with null safety

Here is my json file which I want to convert to dart model { "data": { "catalog_id": "615ac5699a3c9f2ea3a65180", "catalog_images": { "l_large": { "url": "" }, "l_medium": { "url": "" }, …
-2
votes
1 answer

error :The argument type 'Set?' can't be assigned to the parameter type 'Set

onTap: widget.isSelecting ? _selectLocation : null, markers: (_pickedLocation == null && widget.isSelecting) ? null : { Marker( markerId: MarkerId('m1'), …
-2
votes
1 answer

Flutter: null safety updates get me some errors in code

I have a project was made before null safety, now the code has a lot of errors I was fixed all error except this two errors shown below, and I'm not sure what should I do about this The first error: The first…
slackgate
  • 57
  • 2
  • 7
-2
votes
1 answer

Dart Null Safety Concept is not cleared

Dart null safety says that by default all variables of primitive data types (int, String, bool) are non-nullable, they can't have a null value, right? Let suppose if I have a variable 'a' of type int then I can't assign it a null value unless to use…
Muhammad Afzal
  • 118
  • 1
  • 9
1 2 3
78
79