Category "dart-null-safety"

"Bad state: Cannot call `when` within a stub response", "type 'Null' is not a subtype of type [...]"

I wrote a few unit and widget tests for my Flutter app. They all pass when called from the testing window out of VSCode: But when I call flutter test from the

Flutter: Unable to migrate to null safety

I am following this guide to migrate my project to null safety: https://dart.dev/null-safety/migration-guide But I am facing this issue with the dart migrate co

Can anyone please explain the use of null-shorting cascade in Dart?

I'm confused about what the documentation says here:

How is Dart "sound null-safety" different from Kotlin null safety?

This Dart official video states that Dart's so-called "sound null safety" is better than Kotlin's null safety design, because it can optimise the code based on

Null safety migration error: package has unmigrated dependencies. But all my dependencies declare support for null-safety

Im trying to migrate dart null safety but I get the following error when I run dart migrate Bad state: Error: package has unmigrated dependencies. Before migra

The parameter can't have a value of 'null' because of its type in Dart

Dart function I have the following Dart function and I am now using null safety: void calculate({int factor}) { // ... } The analyzer complains that: The pa

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

I have a refactored widget which has an onPressed. But whenever I try to access that function, I get this error : The argument type Function? can't be assigned

Dart: Custom "copyWith" method with nullable properties

I'm trying to create a "copyWith" method for my class, and it works with most scenarios. The problem is when I try to set a nullable property to null, because m

The argument type 'List<DropdownMenuItem<dynamic>>' can't be assigned to the parameter type 'List<DropdownMenuItem<String>>?

Currently, I am working on a Flutter tutorial which was developed on previous versions. The error occurred once we updated to the latest version of Dart and Flu

How to implement null-safety in simple flutter-dart code with object snapshot.data?

I am new to flutter/dart coding, please help me solve the following: Here is my code trying to fetch data from the FireStore collection "DinnerNames" but I get

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.fami

Flutter: json_serializable ignore nullable fields instead of throwing an error

Suppose there are two models User and City @JsonSerializable() class User { int id; String name; City? city; List<Map<String, City>>

Dart "--no-sound-null-safety" flag not working

I am trying to run a dart file without null safety using the command line. The file is: sandbox.dart void main() { String a; print(a); } I then run the

Dart "--no-sound-null-safety" flag not working

I am trying to run a dart file without null safety using the command line. The file is: sandbox.dart void main() { String a; print(a); } I then run the

Flutter: Dart Error: RangeError (index): Invalid value: Only valid value is 0: 1

Hey guys I am new to Flutter and trying to build a variation selector for an eCommerce application. I am getting this error while trying to build a size variati

FLUTTER Error: Method 'copyWith' cannot be called on 'TextStyle?' because it is potentially null

Wow I have a whole lot of these: Error: Method 'copyWith' cannot be called on 'TextStyle?' because it is potentially null. 'TextStyle' is from 'package:flutter