'Allowing null and asserting it's not - flutter framework

I came across this file https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/widget_span.dart and on line 98, I find this strange that the list declared as parameter :

List<PlaceholderDimensions>? dimensions

is set as nullable. Yet, 2 lines further, it seems to be rejected by :

assert(dimensions != null);

I am thinking that it could be a mistake, but it's Google, so I prefer asking.

Anyone has an idea of why this could be useful for dart / flutter?



Solution 1:[1]

@jamesdlin - you were right.

https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/painting/inline_span.dart is a superclass.

On line 220, it's defining the build function and this other widget is overriding it with more constraints.

Thanks !

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3705905