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 argument type 'TextStyle?' can't be assigned to the parameter type 'TextStyle'

I am getting this error... code snippet that is throwing this error: catalog.desc.text.textStyle(context.captionStyle).make(),
-1
votes
1 answer

Flutter: await and then - baffling behavior

ImagePicker _picker = ImagePicker(); // from image_picker.dart try { XFile? pickedFile = await _picker.pickImage(source: source); do xyz; } catch (e){ ...something } vs try { _picker.pickImage(source: source).then((file)…
Sunil Gupta
  • 666
  • 6
  • 20
-1
votes
1 answer

Flutter: How can i make multiple screens for each element of nested list?

I want to implement App as like given reference App, So i'm looking for that Logic. i have implemented logic for add various elements into list but how can i make multiple screens on tap of ListTile for reference app visit…
-1
votes
1 answer

The argument type 'Null' can't be assigned to the parameter type "" in Flutter

How can I fix the null value error. i'm using the bloc pattern. Please check the below image. Thanks in Advance.
Alpit Panchal
  • 709
  • 1
  • 7
  • 25
-1
votes
2 answers

Please Solve this problem .... "type 'Image' is not a subtype of type 'String"

import 'package:e_comaece/widget/back_layer.dart'; import 'package:flutter/material.dart'; import 'package:backdrop/backdrop.dart'; import 'package:carousel_pro_nullsafety/carousel_pro_nullsafety.dart'; import…
SIDDEK
  • 3
  • 2
-1
votes
1 answer

'Future' is from 'dart:async'. return null;

Future insertToDatabase({ required String title, required String data, required String time, }) async { return await database.transaction((txn) { txn .rawInsert( 'INSERT INTO tasks(title, date, time,…
-1
votes
1 answer

How can I solve type Null is not a subtype of type 'WeatherData'

I'm trying to render weather forecast data, but having issues rendering. in WeatherItem.dart import 'package:flutter/material.dart'; import 'package:forecast/models/weather_data.dart'; class WeatherItem extends StatelessWidget { final WeatherData…
Kim
  • 85
  • 5
-1
votes
3 answers

"Cannot run with sound null safety" Flutter an existing Project?

I had an existing application which i want to modify, I am using following dependencies: path_provider: ^2.0.8 http: ^0.13.4 html: ^0.15.0 custom_pop_up_menu: ^1.2.2 share: ^2.0.4 connectivity: ^3.0.6 flutter_swiper: ^1.1.6 Following…
Qasim Ali
  • 434
  • 2
  • 5
  • 31
-1
votes
2 answers

The argument type 'bool?' can't be assigned to the parameter type 'bool'

I am developing a Flutter App and I got the error The argument type 'bool?' can't be assigned to the parameter type 'bool'. How I solve it? Here is the part of my Code where the error appears. I also google the error and they said, I shound change…
user17784209
-1
votes
1 answer

A value of type 'Employee?' can't be assigned to a variable of type 'Employee' because 'Employee?' is nullable and 'Employee' isn't

Error: A value of type 'Employee?' can't be assigned to a variable of type 'Employee' because 'Employee?' is nullable and 'Employee' isn't.
Ah Hea Sk
  • 13
  • 1
  • 2
  • 4
-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

What's better, an empty non-nullable string or a null and nullable string?

Whether to choose a null nullable container or an empty non-nullable container can be settled convincingly. A similar question appears to be harder to answer using the same argument. Quite likely both options are open. Hence to answer this question…
Sam
  • 563
  • 5
  • 15
-1
votes
1 answer

Expected a value of type 'Widget', but got one of type 'Null'

i am learning responsive web but i am stuck here in some kind of error like Expected a value of type 'Widget', but got one of type 'Null' don't know how to fix this error i tried a lot but i think i can't solve this without someone's help. import…
-1
votes
1 answer

Flutter Null Safety error while creating a Timer | Flutter

I getting this error while i shift my project from old version to new null safety version. Here it show error The method '-' can't be unconditionally invoked because the receiver can be 'null'.Try making the call conditional (using '?.') or adding a…