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

Flutter Null Safety Error in snapshot.data.length

I'm getting this error when I changed my project from without null safety to null safety. The error I got is: "The property 'length' can't be unconditionally accessed because the receiver can be 'null'.Try making the access conditional (using '?.')…
Murali Krishnan
  • 272
  • 5
  • 20
0
votes
3 answers

How to downgrade dart back to dart 1.x in Flutter?

I accidentally upgraded dart and flutter to the newest version but my code don't support null safety yet. Now I want to downgrade back to dart 1.x. I tried flutter downgrade v1.2.1 but nothing changed. How can I downgrade back to dart 1.x?
Dalon
  • 566
  • 8
  • 26
0
votes
2 answers

How to add a Flutter plugin that does not support Null Safety

Hay, I want to make a "Privacy Policy Checkbox" that includes a Text Hyperlink, and I found Link Plugin in pub.dev that what I want to use, but unfortunately it doesn't support Null Safety. I am running in flutter 2.5.1. When I used the Link Widget…
0
votes
2 answers

cant refactor color with shade in Flutter

I am trying to refactor my code. This is my Code ,I am getting Problem import 'package:flutter/material.dart'; class AppBarButton extends StatelessWidget { const AppBarButton( {Key? key, required this.buttnoAction, …
Leskeboy
  • 107
  • 1
  • 1
  • 9
0
votes
1 answer

Flutter dart null safety migration dont work because of package flutter_template_images

I want to migrate my project to null safety but the dependecie flutter_template_images is not supporting null safety: Package Name Current Upgradable Resolvable Latest direct dependencies: flutter_template_images ✗4.0.0 ✗4.0.0 …
Dalon
  • 566
  • 8
  • 26
0
votes
1 answer

Best practice for repeated null checks

My app has a public area, and an area where users must be authenticated, for example a page with a chat. At the lowest level I have my authenticationService, where I can check if a user is authenticated by checking for null…
Christian
  • 558
  • 2
  • 13
0
votes
1 answer

Calling a method if object is not null (Using null safety with void methods)

Is there a way to do such thing as void? callMe()? Because there is no type such as void? and hence calling this method null object with result in error above. void main(List arguments) { User? user; print(user?.callMe()); …
Mahamat
  • 321
  • 4
  • 14
0
votes
0 answers

type '(dynamic) => Product' is not a subtype of type '(String, dynamic) => MapEntry' of 'transform'

I am trying to consume data from an API. I used quicktype.io to create a model class to parse the JSON data. The JSON data contains nested maps. Now I am getting an error The error is [type '(dynamic) => Product' is not a subtype of type '(String,…
0
votes
2 answers

Flutter: Cast error in sku_details_wrapper.g.dart

i'm having some truble in Flutter. flutter doctor -v output: [✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-x64, locale en-IT) • Flutter version 2.5.1 at /Users/me/Developer/flutter • Upstream repository…
Marco
  • 1
  • 1
  • 2
0
votes
0 answers

Unable to Login if File is null

I'm using Firebase in flutter Project it's simple Login/ Signup. I have check isLogin mode or not everything is working fine in signup mode but not able to login. It's giving error like this => Null check operator used on a null value My…
0
votes
2 answers

flutter variable scope in stateless class

When I try to capture the TextField value to the variable and display value by using TextButton it gives the following error message. "The non-nullable local variable 'str' must be assigned before it can be used. (Documentation) Try giving it an…
ishara
  • 9
  • 1
0
votes
1 answer

How to Combine Two Seperate List in To List of Object

How to convert two Seperate list into List of Object in Fluter,dart class Task { String name; bool isDone Task({this.name,this.isDone = false}); } How To Convert this two List in to List as below mention List taskname = ['buy milk','go…
0
votes
1 answer

Flutter : The argument type 'void Function(Country)' can't be assigned to the parameter type 'void Function(Country?)?'

I faced with an error using country_currency_pickers, i suppose it's because the function should turns into null safety, but i don't know how to do this. Thanks for help in advance! Widget _buildDropdownItem(Country country) => Container( child:…
anderson48
  • 35
  • 1
  • 7
0
votes
2 answers

Dart null-safety breaks Future anonymous method?

Prior to migrating to null safety this worked. This is a user login verification method. Future loginValidate() async { final String dir = await getDocDir(); //getting documents directory try { await…
Demiurge
  • 3
  • 2
0
votes
1 answer

How to fetch json Array with flutter null safety?

I want to display restaurent details inside listview. But, i am constantly getting error called "Null check operator used on null" value even if i am getting the json response body. Can anyone help me with this to know where exactly i am going…
Vinay Bakle
  • 133
  • 13