Questions tagged [null-safety]
96 questions
1
vote
0 answers
How to cast Right side of Either to generic type in flutter
I have an extension to Task (from the dartz package) which looks like this
extension TaskX, U> on Task {
Task> mapLeftToFailure() {
return this.map(
// Errors are returned as objects
…

Manu
- 372
- 2
- 12
1
vote
1 answer
How to fix "null check operator used on a null value" in flutter?
I am making a todo list app. I wrote the code and used the dart migrate feature for null safety. I don't know how to fix this, can someone please help me.
Error displayed running the app on a device
main.dart
import…

Suryanshu Singh
- 11
- 1
- 4
1
vote
2 answers
Error: the operation '[]' is not defined for the type 'object'
I am using Null -Safety then I keep getting this error, anywhere I user snapshot in my code
here is the error
here is my code
StreamBuilder(
stream: firestore
.collection('interest')
…

Gbenga B Ayannuga
- 2,407
- 3
- 17
- 38
1
vote
1 answer
How to use operators like *= and += with Dart maps and null-safety
If I have a map like:
Map myMap = Map();
Add a key and value:
myMap.putIfAbsent("yolo", 1000);
Then add a number using an operator like +=
myMap["yolo"] += 100;
With null safety it throws an error saying
The method '+' can't be…

Matthew
- 3,411
- 2
- 28
- 28
0
votes
1 answer
Even though I used late for filed in flutter, a null safety error is occurring
In my code, 'db' leads to null safety problem. Below is the code I wrote
class DbHelper{
final int version = 1;
late Database db;
Future openDb() async {
if (db == null){
db = await openDatabase(join(await…

Hyun Kim
- 5
- 2
0
votes
1 answer
Null check operator used on a null value error on login form
════════ Exception caught by gesture ═══════════════════════════════════════════
Null check operator used on a null value
════════════════════════════════════════════════════════════════════════════════
class AuthForm extends StatefulWidget {
…

Kabir kurd
- 1
- 1
0
votes
1 answer
Java: Effect of @NonNull function returning null
I have an old Java function in an Android project that is annotated with @NonNull. A few years after the function was written another developer added a branch that returns null and forgot to remove the annotation. This was discovered a few months…

Marsroverr
- 556
- 1
- 6
- 23
0
votes
0 answers
Error after updating flutter to 3.10.4 The following dependencies do not satisfy the required version:
I recently updated by flutter from 3.3.0 to 3.10.4 and updated my project in null safety.
After that I got kotlin version error and I change my kotlin version from 1.6.10 to 1.8.21.
Also classpath 'com.android.tools.build:gradle:4.1.0' to classpath…

Honey Last
- 255
- 1
- 3
- 15
0
votes
0 answers
how to resolve Error: Library doesn't support null safety. // @dart = 2.9
The language version must be >=2.12.0. error in flutter
I am receiving the following error in the line // @dart=2.9
My dart version is 3.0.3
I am receiving this error due to which my application is not running
Earlier this was working fine now the…
0
votes
2 answers
Flutter pub get error due to Dark SDK version or flutter_launcher_name
I wanted to use pub get using Flutter, and I encountered this error:
C:\src\flutter\bin\flutter.bat --no-color pub get
Resolving dependencies...
The current Dart SDK version is 3.0.0-417.0.dev.
Because flutter_launcher_name 0.0.1 doesn't support…
0
votes
1 answer
Dart variable is clearly not null but Dart thinks it can be potentially null
Why does Dart say the _parent variable is potentially null when there is a trivial if..then checking? How to get past this problem?
class Scope {
late final Map _map;
Scope? _parent;
Scope() : _map = {};
bool has(String key) {
…

B So
- 1
0
votes
0 answers
How to cleanly type optionally nullish parameter that will be returned unchanged
A common pattern in javascript functions is to return an input variable unchanged if it is nullish:
function transform(input) {
if (input == null) return input
return { whatever() {} }
}
In TypeScript, I would like to represent this in a…

Yona Appletree
- 8,801
- 6
- 35
- 52
0
votes
0 answers
The following NoSuchMethodError was thrown building Builder;
I'm new to flutter, and I've got an error everytime I run the application.
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building…
0
votes
3 answers
Flutter error - Invalid argument(s): No host specified in URI nullapi/auth/login/
Fairly new to Flutter and have encountered an issue. I am trying to get the emulator (for both iOS and Android) of my app to connect to an API that is running on my local machine. I had it working up until I upgraded flutter null-safety and have not…

Frank Castle
- 335
- 3
- 23
0
votes
1 answer
The parameter 'abc' can't have a value of 'null' because of its type, but the implicit default value is 'null'
@required to a property gave such ERROR:
The parameter 'lng' can't have a value of 'null' because of its type, but the implicit default value is 'null'. (Documentation)
but removing @, removes the error. how ?
I mean, the value still can be null.…

Saad Mansoor
- 199
- 7