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

Null check operator used on a null value (FutureBuilder)

I am receiving the above null check error code with snapshot. I have investigated a number of similar questions on Stack overflow, but don't seem to get a fix to my problem. I am fairly new to flutter still and would really appreciate some…
0
votes
2 answers

in flutter it shows me an error when i tryed to initialize a string...... it say it cant be null

class Destination { String imageUrl; String city; String country; String description; List activities; Destination({ this.imageUrl, this.city, this.country, …
0
votes
0 answers

couldn't find a null safe version of bezier_chart package flutter

Need a null safe version of bezier_chart flutter, couldn't find it, is there an alternate null safe available for this package?
0
votes
1 answer

How to perform null check on map? I'm not getting it

// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:world_time/pages/loading.dart'; class Home extends StatefulWidget { const Home({Key? key}) : super(key: key); @override _HomeState…
0
votes
1 answer

The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#86032):

I get this error message and have no idea how to fix it: Exception caught by widgets library The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#86032): The method 'call' was called on null. Receiver: null Tried…
0
votes
0 answers

Dart Null Safety -- Flutter Adaptive Layout pt. 1

[SOLVED] so I've been trying to follow the code from flutter boring show ep. 45 about adaptive layouts. the app can run on mobile device at portrait view, but when I turned it to landscape, it's gone error like this : Person…
nas11ai
  • 1
  • 1
0
votes
3 answers

I want to Save Contact Number at Mobile storage using Flutter

I wrote this function to save contact number, but it can't save on local storage Future _saveContact() async { Contact contact = Contact(); contact.familyName = 'FreeZone'; contact.phones = [Item(label: "mobile", value: '01752591591')]; …
0
votes
2 answers

Initializing a future in flutter?

I would like to run a downloading Future function when opening a page in flutter, however it is being called multiple times. I would like to implement a solution like the second in this…
Marco Groot
  • 49
  • 1
  • 6
0
votes
1 answer

Null safety in dart (Null check operator used on a null value)

Hello i know it is very common error in flutter when we deal with dart null safety. I have come to know why this error is occuring but i am unable to fix this error."Null check operator used on a null value" this error appears when we use bang(!)…
0
votes
2 answers

Flutter change slider thumb to image

I want to create something like this. I have managed to create it but anytime I start the app, I get LateInitializationError which says LateInitializationError: Field 'customImage' has not been initialized. before the slider shows. This is my…
0
votes
1 answer

Why is the redirect wrong page from main page?

This is my main.dart page code import 'package:cwc/OnBoard/landing_page.dart'; import 'package:cwc/OnBoard/login_page.dart'; import 'package:cwc/ui/Home/home_page.dart'; import 'package:cwc/ui/signup/signup_page.dart'; import…
Deepak
  • 1,664
  • 3
  • 19
  • 52
0
votes
2 answers

How to return a non-nullable type from a Function in a function callback?

Future getInt() async { // Error: final c = Completer(); await foo.bar( callback1: (i) => c.complete(i), callback2: (j) => c.complete(j), error: (e) => throw e, ); } The body might complete normally, causing 'null' to…
iDecode
  • 22,623
  • 19
  • 99
  • 186
0
votes
2 answers

I am trying to get data from API but having error

This is my model class and I am trying to get all the data but getting error and don't know why. HomePageModel homePageModelFromJson(String str) => HomePageModel.fromJson(json.decode(str)); String homePageModelToJson(HomePageModel data) =>…
Saurav
  • 132
  • 1
  • 12
0
votes
2 answers

Image provider: AssetImage(bundle: null, name: "/assets/google-logo.png")

I am trying to load an image in flutter, but it's showing error output file Directory pubspec.yaml # The following section is specific to Flutter. flutter: uses-material-design: true assets: - assets/ Code const…
0
votes
1 answer

is there way to get a particular data which have been saved using shared preference?

#i Saved all my user data using shared preference to perform autologin and it works well data is saved token = responseData['token']; userEmail = responseData['user_email']; userNicename = responseData['user_nicename']; …
Saurav
  • 132
  • 1
  • 12