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
1 answer

The relevant error-causing widget was StreamBuilder>

I am trying to find the solution for this error, help! how can i solve this ? i use this to make a chat app using firebase ════════ Exception caught by widgets library ═══════════════════════════════════ Bad state: field does not exist within the…
-1
votes
3 answers

Error: Cannot run with sound null safety, because the following dependencies don't support null safety; in flutter

i made a BlocBuilder and then this package can't run with null safety datetime_picker_formfield, i confuse how to fix the error and solve the error, this is the whole code of BlocBuilder: return BlocBuilder
1988
  • 309
  • 2
  • 15
-1
votes
1 answer

how can sollve Problem related to null safety: A nullable expression can't be used as a condition

ChangeFavoritesModel? changeFavoritesModel; void changeFavorites(int productId) { favorites?[productId] = !favorites[productId]; DioHelper.postData( url: FAVORITES, data: { 'product_id': productId, }, token:…
-1
votes
1 answer

The argument type 'Null' can't be assigned to the parameter type 'ClassPenangkap'.can anyone help me?

import 'package:flutter/material.dart'; import 'dart:async'; import 'crud.dart'; import 'class_penangkap.dart'; import 'acces_database.dart'; import 'enter.dart'; class Home extends StatefulWidget { …
-1
votes
2 answers

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

Widget _buildSwitchListTile( String title, String description, bool currentValue, VoidCallback updateValue) { return SwitchListTile( value: currentValue, title: Text(title), subtitle: Text(description), …
-1
votes
1 answer

type 'Null' is not a subtype of type 'Map' flutter error

I get the error: 'Null' is not a subtype of type 'Map' in type cast @override void initState() { FirebaseFirestore.instance.collection('user').doc(widget.id); AsyncSnapshot? snapshot; Map
husam
  • 33
  • 1
  • 6
-1
votes
1 answer

I"m linking my whatsapp to my flutter web and getting this (The argument type 'String' can't be assigned to the parameter type 'Uri'.)

This is the method that i want to use to connect my whatsapp, void launchWhatsapp(@required number, @required message) async { String url = "whatsapp://send?phone=$number&text=$message"; await canLaunchUrl(url) ? launch(url) :…
-1
votes
1 answer

Flutter: The named parameter 'image' isn't defined

I wanna ask some help with my codes. I am lost in which part pf the code I am going to put this image: DecorationImage(image: FileImage(imageFile!), in the scanscreen.dart. I am trying to follow this tutorial from Pick Images from Gallery and…
John Michael Tan
  • 129
  • 3
  • 10
-1
votes
1 answer

I am trying to convert date in Dart. But I am getting a date one day before the specified date. How to solve this error and reason for this?

print(json["end"] + " date before parsing"); print(DateTime.parse(json["end"]).toString() + " date after parsing"); Output I/flutter ( 7101): 2022-07-19T05:00:00+05:30 date before parsing I/flutter ( 7101): 2022-07-18 23:30:00.000Z date after…
Binary_Beast
  • 101
  • 7
-1
votes
2 answers

How to solve null is not subtype of bool?

Getting error while debugging that that null is not subtype of bool I not getting it how to do
S1mple
  • 1
-1
votes
3 answers

The property can't be unconditionally accessed because the receiver can be 'null'...?

Hey guys i have an error and the code is bellow: import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; class ChatScreen extends StatelessWidget { …
-1
votes
2 answers

The argument type 'int?' can't be assigned to the parameter type 'int'. flutter

// I am getting an error at widget.product.id, // The argument type 'int?' can't be assigned to the parameter type 'int'. updateRoutine() async { final productCollection = widget.isar.products; await widget.isar.writeTxn((isar) async { …
Vinodh
  • 9
  • 1
  • 5
-1
votes
1 answer

The property "length" cannot be unconditionally accessed because the reciever can be null

import 'package:flutter/material.dart'; import 'package:notes/db/database_provider.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget…
-1
votes
1 answer

Null Safety App not runnable on Flutter 3.0

I've a Flutter app, that was running properly on Flutter 3.0, but after migrating to Null Safety, I receive this while trying to run: FAILURE: Build failed with an exception. * Where: Script…
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
-1
votes
1 answer

How to extract the text between (%) and (?) from a String?

I want to extract the slug between (%) and (?) from a String url? This is the url as…