Questions tagged [null-check]

A check to see that an object has been instantiated.

A check to see that an object has been instantiated.

Typically, in a OO programming language, this is to see whether an object has been created or not.

e.g (Java example)

public void doStuff(Object obj) {
    if (obj != null) {
        // Do stuff with the object
    }
}
217 questions
0
votes
0 answers

ArgumentNullException when unregistering reminder despite null check

I am using Reminders in my Orleans application, and i have a JournaledGrain that does implement the IRemindable interface. At the end of the flow i make sure i use UnregisterAsync. The reminder gets registered with the grain's identity.The IReminder…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
0
votes
1 answer

How to return a nullable List from an object that can be null with streams

I have a method that takes an object having an ArrayList inside: private List getWatchlistDetail(MatchData k) { if(k == null) return new ArrayList<>(); return k.getWatchListDetail() …
0
votes
1 answer

Convince static null check when calling function as parameter,

EDIT: My gist seems to work, ie, I dont get any problems... so I guess the problem lies elsewhere. Ill keep this post open for a short while, then close it I have this class Result public class Result { public T? Data { get; private set; } …
Cowborg
  • 2,645
  • 3
  • 34
  • 51
0
votes
1 answer

Sonar does not accept null check via method

Sonar does not accept the control when we check for null via method. What can be the solution? It only accepts when you do as follows: if (callID == null) { throw new ArgumentNullException(nameof(callID)); } It doesn't see it when I do it like…
0
votes
1 answer

Flutter: null check operator used on a null value error

I'm working on a simple e-commerce app. And I got an error as follows: E/flutter (13586): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value Can't figure what's causing this error even though I…
Moh Say 21
  • 81
  • 1
  • 1
  • 5
0
votes
3 answers

Null check operator used on a null value issue in flutter

I have the issue of _CastError (Null check operator used on a null value, its happened in openstreet map included in Flutter project when i choose service of car in rider app and greate reuest of ride. check the code : import…
0
votes
2 answers

Null check operator used on a null value (FutureBuilder)

I am receiving the above null check error code with snapshot. I have investigated a number of similar questions on Stack overflow, but don't seem to get a fix to my problem. I am fairly new to flutter still and would really appreciate some…
0
votes
2 answers

Do @NotNull annotations on getters have signifcant impacts on performance?

Random example: In the source code of one of my programs I have this method: public @NotNull Currency[] getCurrencies() { return this.currencies.values().toArray(new Currency[0]); } Which, after being compiled, gets turned into the…
jaylawl
  • 105
  • 6
0
votes
1 answer

Deep null check inside linq expression, is there a better way?

Unless it's in the Linq expression I could use the operator "?.". But since I can't use it in Linq, it's bad code writing. How can I do a deep null check? _collection.Select(x=> new CollectionModel { Title = x.CollectionValues != null && …
codinges
  • 61
  • 6
0
votes
3 answers

What is HasValue and .Value equivalent in TypeScript

I have a method : public cancelOperation(OperationId: string): Promise { // some calls } I get OperationId from another method : let operationId = GetOperationId() {} which return nullable OperationId, operationId?: string; so…
Rajdeep
  • 788
  • 7
  • 26
0
votes
1 answer

How to make "compute()" function insert data to sqlite while in isolated process?

I'm working on flutter app that uses php apis for server and sqlite for local data. The problem is with "compute()". Here is the explanation : I have three functions that receives data from api on the server, then add the data to my local database…
alnajm
  • 335
  • 1
  • 2
  • 14
0
votes
1 answer

How to implement Null checker in Dart

I'm learning Dart for the first time. I have learned the concept of exception handling, and I also learned that we can specify null checker, which edits a variable if it's value become null. I have shared the code that I got from my tutor. void…
FadedCoder
  • 25
  • 3
0
votes
3 answers

How to check null on length in flutter?

I am trying to fetch data from an API but unable to get because of this length error. "The property 'length' can't be unconditionally accessed because the receiver can be 'null'.\nTry making the access conditional (using '?.') or adding a null check…
Javeria
  • 5
  • 5
0
votes
1 answer

Null check operator used on a null value, Bang(!) Operator Issue

I'm writing a code where an Admin is uploading images to firebase. The error comes when I put an if else statement to two functions first function allows you to capture images at Admin's home screen from camera and gallery and the second function…
M Nouman
  • 437
  • 1
  • 5
  • 22
0
votes
1 answer

Flutter Firebase document field null check inside ListView

i have a FutureBuilder with a ListView.builder. Inside that i want to show a container with a text only if a FIELD from the document exists. I have tried the following from the documentation and from multiple stack answers but no…