Questions tagged [null-safety]
96 questions
0
votes
4 answers
How to take integer input from user in dart
i am new in dart and just want to know how to take integer input from user in dart with null safety. i found out a way to take number input from dart which is:
String? chossenNumber = stdin. readLineSync();
if(chossenNumber !=null)
{
int…

Saad Ebad
- 206
- 5
- 16
0
votes
1 answer
Is there a way in PHP to use null coalesing/nullsafe operators to default to not set any value?
I only see use cases were null coalesing can be used to chain values, but not to omit any value.
Am I missing something essential or is there really no shorthand way to write this:
$model->name = "Example";
if(isset($input->name)) {
$validName…

Alex
- 29
- 5
0
votes
2 answers
The argument type 'List?' can't be assigned to the parameter type 'List?'
i have recently migrated my code to null safety. got the below error in dart migrate command.
The argument type 'List?' can't be assigned to the parameter type 'List?' at…

Venki
- 33
- 4
0
votes
1 answer
Null aware assignment of map entry
Is there an elegant way to write the following statement for a map?
String? img = json['image'];
if (img != null) {
json['image'] = 'https://example.com/ingredients_100x100/' + img;
}
Basically I want to append the image IFF it exists and…

lhengl
- 70
- 5
0
votes
1 answer
Stateful Classes Flutter project
I'm trying to generate a Flutter app, to create a stateful text field that I can call from other class (passing a name of the field and a limit for the field)., but I don't know how to do that,
Basically, I'm trying to be concise and reduce the…

MoStafa SelieM
- 1
- 1
0
votes
3 answers
Why im getting this error Warning: Operand of null-aware operation '??' has type 'String' which excludes null. Dart Language
so i was learning about SWITCH and CASE Statements in dart language, in the course he explains the code but he don't get an error while i get one.
the error i get
: Warning: Operand of null-aware operation '??' has type 'String' which excludes…

Yamix.co
- 3
- 1
- 3
0
votes
1 answer
Firebase doesn't work cause of null-safety (DART/FLUTTER)
I'm using/learning Firebase for my database works. My snapshot's coming like _jsonQuerySnapshot or _jsonDocumentSnapshot. But it had to be QuerySnapshot or DocumentSnapshot. Because of this I have to encode and decode my snapshot for use my…

demonjoseph
- 211
- 1
- 3
- 10
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…

Omojola Samson
- 1
- 1
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
2 answers
Method 'showBottomSheet' cannot be called on 'ScaffoldState?' because it is potentially null
Hello I'm getting this error when I tried to run the code
lib/layout/home_layout.dart:54:36: Error: Method 'showBottomSheet' cannot be called on 'ScaffoldState?' because it is potentially null.
- 'ScaffoldState' is from…

Diaa Nassar
- 59
- 2
- 7
0
votes
1 answer
indicates versions without null safety support
I'm tryna enabled null-safe property. that's why I wrote "dart pub outdated --mode=null-safety" but I got error below:
indicates versions without null safety support

zey.s
- 13
- 4
0
votes
0 answers
The property 'xyz' can't be unconditionally accessed because the receiver can be 'null'
I was upgraded my flutter project version to the latest (2.5.3). then occurred some errors due to unsupported null-safety. I had fixed many but still, haven't any idea to fix following null-safety to error,
Code
itemBuilder: (context, suggestion) {
…

Tharindu Lakshan
- 3,995
- 6
- 24
- 44
0
votes
1 answer
The argument type 'List' can't be assigned to the parameter type 'Iterable
I have upgraded my Flutter project version to the current latest flutter version (2.5.3) after upgraded occurs this error.
Code as follows,
final List

Tharindu Lakshan
- 3,995
- 6
- 24
- 44
0
votes
2 answers
what is other solution for "required" in null safety to get uid in firestore?
I'm learning flutter from the older version with the new one. so, I have many times problem with null safety.
I have code in database.dart file like this :
import 'package:cloud_firestore/cloud_firestore.dart';
class DatabaseService {
final…

DVCone
- 109
- 2
- 12
0
votes
1 answer
Closure call with mismatched arguments: function 'LoginScreen.build.
Hello I'm getting this error when I tried to run the code
Here is the full error:
======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown building…

Diaa Nassar
- 59
- 2
- 7