Questions tagged [null-safety]
96 questions
-1
votes
1 answer
How best to convert old Dart code that triggers "parameter can't be 'null' but the implicit default value is 'null'." error?
Take the following non-null safe Dart code:
class RoundedButton extends StatelessWidget {
RoundedButton({this.title, this.color, @required this.onPressed});
final Color color;
final String title;
final Function onPressed;
@override
…

Nerdy Bunz
- 6,040
- 10
- 41
- 100
-1
votes
1 answer
How best to convert old Dart code that triggers "The non-nullable variable must be assigned" error?
Take the following non-null safe Dart code:
static String appBarShiftTitleString(int fromEpochSeconds) {
String monthWord;
String dayWord;
DateTime dt = DateTime.fromMillisecondsSinceEpoch(fromEpochSeconds * 1000);
switch…

Nerdy Bunz
- 6,040
- 10
- 41
- 100
-1
votes
1 answer
I'm having the following error in the console and i been trying to fix it for hours
This the is error console is showing. It says it's in Root widget
This is my code
'''
initState: (_) async {
Get.put(UserController());
},
builder: (_) {
if (Get.find().user?.isEmpty == true){
…

Wai Yan
- 11
- 4
-1
votes
1 answer
type 'Null' is not a subtype of type 'int'
I was studying flutter. I got this error at the end and I'm not sure what to do. I would appreciate it if you could tell me how. I'm sorry if my English is not good enough, please forgive me.
I also got this error in the terminal.
It is part of the…

LiDe
- 35
- 1
- 7
-2
votes
1 answer
What has the difference between declaring a variable with var and int do with the Null Safety?
Why does Dart allow this:
void main() {
var A;
A ??= 12;
print(A);
}
The output is 12. But not this:
void main() {
int A;
A ??= 12;
print(A);
}
Here's the error:
lib/project_dart.dart:4:2: Warning: Operand of null-aware operation '??='…

ZahRaF
- 13
- 2
-2
votes
1 answer
I'm new to flutter and trying to use spread operator and Map into a List but I get null safety error , tried using (!) but no good
enter image description here
I'm new to flutter and trying to use spread operator and Map into a List but I get null safety error , tried using (!) but no good.

shaikh usama
- 1
- 1