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

Non-nullable instance field '_bmi' must be initialized flutter

I am having an error with my dart code, which I tried using "?" but still it didn't work. I am seeing this error message "Non-nullable instance field '_bmi' must be initialized flutter" import 'dart:math'; class CalculatorBrain { final…
0
votes
1 answer

Flutter null-safety migration - top_snackbar_flutter

I did a dart migrate to update my project to null-safety. I have several issues to sort as it was an old project. However, one thing is stumping me a lot and unable to figure out a way. I am using top_snackbar_flutter package and updated the same to…
Vivian Lobo
  • 583
  • 10
  • 29
0
votes
1 answer

How can I solve this Flutter GraphQL null safety error?

I'm trying to use graphql_flutter's Subscription widget but my app fails to compile. I keep getting a null safety error: Error: The argument type 'Widget Function({dynamic error, bool loading, dynamic payload})' can't be assigned to the parameter…
0
votes
2 answers

error : I get error ' Unexpected null value' when I run app

1.This is first code : DateTime? _selectedTime; void _datePicker(BuildContext con2) { showDatePicker( initialDate: DateTime.utc(2021, 12, 21), firstDate: DateTime(2000), lastDate: DateTime.now(), context: con2, …
0
votes
1 answer

Flutter custom background does not display after updating to null safety

I recently upgraded my flutter project to null safety and my page stopped showing the body of the scaffold. I think the problem is with the Mediaquery even tho I am not sure about it. I am using a custom background to design my page, the…
ANDREW EBARE
  • 85
  • 1
  • 9
0
votes
2 answers

How to add //@dart=2.9 in dart file

Now I'm working in flutter project. I need to add //@dart=2.9 in dart file. But i got run time error. Like A library can't opt out of null safety by default,when using sound null safety. How can i add it on dart file?
Ammukrish
  • 85
  • 1
  • 8
0
votes
3 answers

Dart null safety with if check

I am use Dart Null Safety version Have a widget: itemBuilder expects a Widget type. footer is Widget? type and will be null Why Dart ignoring my null check? Also I only found one solution: if (footer != null && index == data.length) { return…
Leonid Veremchuk
  • 1,952
  • 15
  • 27
0
votes
1 answer

1 positional argument(s) expected, but 0 found. Try adding the missing arguments

I have the code which i have been trying to work on but I keep getting this error: 1 positional argument(s) expected, but 0 found. Try adding the missing arguments. And I have looked at other issues like this on this forum but none can solve mine…
Britchi3
  • 180
  • 5
  • 17
0
votes
1 answer

Null check operator used on a null value Flutter

I know this problem is related with dart null safety but i am unable to fix this issue as i am getting this 'Null check operator used on a null value Flutter' error.Please help me to fix this my code is: class _ListStudentPageState extends…
Saad Ebad
  • 206
  • 5
  • 16
0
votes
0 answers

Error: Class 'Future' has no instance getter 'contacts'. Receiver: Instance of 'Future'. When Trying to access list of number

I have an issue with a list I've created. I've added the numbers from my contacts list to a list. I want to use these numbers to send a text using phoneController, which takes a string of numbers:_phoneController.text =…
DipaJS
  • 11
  • 3
0
votes
1 answer

Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe Navigator.push after migration to null safety

I have migrated all my packages of the project to null safety. Due to some thinks that I have to handle on the Android (Kotlin), extending a third party library. After doing that now I receive the following error: E/flutter (14210):…
el.severo
  • 2,202
  • 6
  • 31
  • 62
0
votes
1 answer

Material banner with stack not found

Today upgrade my flutter sdk for 2.8 and my widget break Flutter sdk 2.5: The material bannner overleap my UI My UI in Flutter sdk 2.5 Flutter sdk 2.8: Material banner displace my UI My UI in flutter sdk 2.8 Flutter doctor Running flutter…
0
votes
2 answers

The argument type 'String?' can't be assigned to the parameter type 'String & Method can't be unconditionally invoked because to receiver can be null

I'm new to Flutter and I've been trying to use the package contacts_service to be able to have a list with names & numbers from your contacts. Below is the code of attempt, however "title: Text(contact.displayName)" gives me the error displayName…
DipaJS
  • 11
  • 3
0
votes
1 answer

How to replace transformEvents in Flutter while using bloc?

I recently upgraded a Flutter project and all its dependencies. Earlier I was using bloc: ^6.1.1 which is now upgraded to bloc: ^8.0.1. But transformEvents was removed in 8.0.0 version which was being used like this in the code. @override …
Bhawna Saroha
  • 603
  • 1
  • 11
  • 28
0
votes
2 answers

lateIntailizatationError and Nullcheckoperator

when I compiled my app the error{LateInitializationError: Field 'contorller' has not been initialized} appeared and when I changed the Late keyword with ? operator and Put ! before the methods that depends on the variable like stackoverflow suggests…