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

lists in null safety issue

i'm getting a null safety issue about with a list from models The default 'List' constructor isn't available when null safety is enabled.Try using a list literal, 'List.filled' or 'List.generate'. this is the code: var productList =…
taki taki
  • 1
  • 1
-2
votes
1 answer

Null check operator used on a null value on safe area

help me, I'm still stuck here for the past few days. why is it like this? error indicates there is an error in "dashboard_bottom_nav" and when I try to click the error it directs me to this class and directs it to SafeArea I really need your help
Ewa Saputra
  • 167
  • 3
  • 11
-2
votes
1 answer

How to do a multi check for null values after Dart null safety?

int? foo, bar, baz; bool get allGood => foo != null && bar != null && baz != null; void f1() { if (allGood) { print('${foo.abs()} ${bar.abs()} ${baz.abs()}}'); // Error } } void f2() { if (allGood) { print('${foo.ceil()}…
iDecode
  • 22,623
  • 19
  • 99
  • 186
-2
votes
2 answers

named parameter in Dart

Good day, I am trying to apply named parameter {num phone} to the below example: main(){ showInfo("abc@mail.com", "Fatima"); } String showInfo(String email, String name, {num phone}) { print(email); print(name); print(phone); return "$email :…
StarCrossed
  • 341
  • 1
  • 3
  • 10
-3
votes
1 answer

checking variable null-safety with ! and?

I trying to understand the basics of null-safety in dart what is the best use for this: // model class MyModel { String? name; MyModel({this.name}) } // view-controller MyModel? response; // do some async operations here, on success response…
Igor
  • 399
  • 4
  • 18
-3
votes
1 answer

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

import 'package:flutter/material.dart'; import 'package:foodcorner/color/colors.dart'; enum SinginCharacter {fill,outline} class ProductDetails extends StatefulWidget { const ProductDetails({Key? key}) : super(key: key); @override …
-3
votes
3 answers

How to make model of array object in flutter

[ { "Id": 1, "Value": "Planned Annual" }, { "Id": 2, "Value": "Unplanned annual" }, { "Id": 3, "Value": "Sick Leave" }, { "Id": 4, "Value": "Working From Home" }, { "Id": 5, "Value": "Excuse" }, { "Id": 6, "Value": "Maternity leave" }, { "Id":…
-3
votes
1 answer

why does i get non-nullable error in flutter

I am developing a flutter project, but I get this error and I don't know how to solve
Mohamad Jabaly
  • 119
  • 2
  • 10
-3
votes
1 answer

What's the state of support for null safety for the HERE SDK for Flutter?

We're deciding between here sdk and few others for our app, wondering what's the state of null safety, is it possible to use it with null safety app? What's the progress of migration, is there any timeframe we could expect sdk for flutter 2.2.2?
-4
votes
2 answers

HOW TO SOLVE THIS IN DART?

import "dart:math"; import "dart:io"; void main(){ print("enter first number"); double num1 = double.parse(stdin.readLineSync()); print("enter second number"); double num2 = double.parse((stdin.readLineSync()); print ( num1 + num2 …
Jsent
  • 9
  • 1
-4
votes
1 answer

Confusion with Null safety

I'm pretty new to flutter and because of the null safety feature I've been getting a lot of errors from a code that will run perfectly fine in Java or other langs. For example this- int ? i; var icecreamFlavours = ['chocolate', 'vanilla',…
Logic
  • 53
  • 1
  • 9
-4
votes
1 answer

Null Safety equivalent of "List>()"?

My old working code: List> pages = List>(); Now doesn't work with null safety: The default 'List' constructor isn't available when null safety is enabled. Try using a list literal, 'List.filled' or…
manafire
  • 5,984
  • 4
  • 43
  • 53
-5
votes
1 answer

Importing Package in Flutter

I have an issue to solve an error which I am facing past 3 days, begin the journey in coding since months but I can't get Errors. Here is the Snippet of Todo List code. import 'package:flutter/material.dart'; void main() { …
-5
votes
1 answer

Dart throws LateInitializationError even when I initialize variables in initState

I'm declaring two variables using the late keyword, so that I can initialize both of them in the initState function. class _CustomNavBarState extends State with TickerProviderStateMixin { late AnimationController…
geomikeo
  • 9
  • 2
1 2 3
78
79