Questions tagged [nullable]

The nullable tag is for issues relating to nullable members or types. A null is used to represent a missing or unknown value.

A data member is nullable if it can have the special value of NULL, instead of their common range of possible values. Nullable types are a feature of some statically-typed programming languages.

.NET

In , the built-in generic type System.Nullable<T> allows the programmer to use value types like int or DateTime with a value of null. Several .NET languages have a special syntax for declaring Nullable:

  • In , int? is an alias for System.Nullable<System.Int32>
  • In , Integer? is an alias for System.Nullable(Of System.Int32)

SQL

Null is a special marker used in SQL to indicate that data value do not exist in the database. Its proper use ensures various statistical aggregate functions perform correctly.

See more on Wikipedia.

D

The typecons module in package std has a templated struct - Nullable - for wrapping values types and allowing them to appear to have a null value (as in C#). Restriction is that the type must be able to be instantiated with T var or T var = T.init, where T represents the type being used.

Related tags

2417 questions
1
vote
2 answers

'int?' does not contain a definition for 'TryFormat'

I am having a hard time understanding how nullable value types works in C#9. Following documentation from: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types I can write (no compiler error): int?…
malat
  • 12,152
  • 13
  • 89
  • 158
1
vote
3 answers

How can I use a `Task` instance as a Task parameter to a method?

How can I use a Task instance as a Task parameter to a method? If I am using nullability enabled, and I have two async methods like.. // in an ordinary class public async static Task Foo() { ... } // in a static…
Patrick Szalapski
  • 8,738
  • 11
  • 67
  • 129
1
vote
1 answer

The parameter 'image' can't have a value of 'null' because of its type, but the implicit default value is 'null'

I don't understand the issue with the following Code and would love to hear some ideas on how to solve my problem Code: class SplashContent extends StatelessWidget { const SplashContent({ Key? key, this.text, this.image, }) :…
1
vote
1 answer

C# Generic return type must be non-nullable to match overridden member, even though overridden member is nullable

You can see the error here: https://dotnetfiddle.net/U8erNX Basically, I make a generic abstract class. When I implement the class, I am not allowed to use nullable, even though I use it in my abstract class... public abstract class A { …
user2154768
  • 890
  • 3
  • 8
  • 16
1
vote
1 answer

Define type that is no longer undefined after data fetched Typescript

Is there a way to tell TypeScript, that a certain type is no longer nullable if a certain call has been made in the code before? So for example I have a call to an API and afterwards I know that the data is defined. But this call is happening…
uloco
  • 2,283
  • 4
  • 22
  • 37
1
vote
1 answer

Is there any NotNull annotation in dart?

I have this little class: class WidgetToImage extends StatefulWidget { final Function(GlobalKey key) builder; const WidgetToImage({Key? key, @required this.builder}) : super(key: key); @override _WidgetToImageState createState() =>…
Notbad
  • 5,936
  • 12
  • 54
  • 100
1
vote
0 answers

Nullable default parameter with generic type on class

I have type with one generic type argument, that contains a method with and an optional parameter. The code treats the nullability of that type in an unexpected way when constructing the default argument. This is closely related to Nullable default…
Adam V. Steele
  • 559
  • 4
  • 18
1
vote
2 answers

Nullable default parameter with generic type

I have a method with one generic argument, and an optional parameter. The compiler seems to be ignoring the nullability of that type when constructing the default argument. This behavior seems inconsistent with how a default value of local variable…
Adam V. Steele
  • 559
  • 4
  • 18
1
vote
1 answer

Flutter path_provider package error with Hive Database and null safety

I have this error in my Flutter Project when I try to use Hive with path_provider. Is there any way to resolve this because i tried switching between beta and master channel and also setting flutter sdk min to 2.11. This error is displayed when I…
David Skela
  • 79
  • 1
  • 6
1
vote
1 answer

Error with TypeScript Generics (Using `Partial` for `? super T`)

TypeScript compilation fails due to an error related to generics that I can not explain. I have created a minimal example: interface Processor { process(data:T):void; } class ArrayProcessor implements Processor|null> {…
jonas
  • 637
  • 1
  • 7
  • 9
1
vote
1 answer

Why mapping nullable collection is always not null in dart?

1 factory SuggestSessionResult.fromJson(Map json) { 2 final String? error = json['error']; 3 final List>? items = json['items']; 4 return SuggestSessionResult( 5 items 6 …
IL_Agent
  • 707
  • 3
  • 16
1
vote
2 answers

DateTime? Cannot assign a value

I need to have a property that is a nullable date as the datestamp is used for when a process is completed. If there is no date this is a way to determain if the process has occured. I have created a Nuallable DateTime property (DateTime?) however…
Christopher Leach
  • 568
  • 1
  • 5
  • 16
1
vote
2 answers

Map key is a String but returns "Object?"

I have the following List of Maps: var questions = [ { 'questionText': 'What is your favorite color?', 'answers': ['Black', 'Green', 'Red', 'White'], }, { 'questionText': 'What is your favorite animal?', 'answers': ['Pig',…
Osman
  • 11
  • 1
1
vote
1 answer

Argument type String? can't be assigned to the parameter type 'String'

With the code below I get the following error message: The argument type 'String?' can't be assigned to the parameter type 'String'.dart(argument_type_not_assignable) The part of the code producing the error (at least I think it does) is the…
sboom
  • 37
  • 4
1
vote
1 answer

Nullable List Parameter in .Net Core 3.1 Web API

Hi I have the following route in my web api: [Route("Resource/")] [HttpGet] public IActionResult Get([FromQuery] IEnumerable filterItems = null) { } In .Net Framework 4.8, whenever I would call this without specifying any filterItems it…