maybeResolve method Null safety
- Color? resolvable,
- BuildContext context
Resolves the given Color by calling resolveFrom.
If the given color is already a concrete Color, it will be returned as is. If the given color is null, returns null. If the given color is a CupertinoDynamicColor, but the given BuildContext lacks the dependencies required to the color resolution, the default trait value will be used (Brightness.light platform brightness, normal contrast, CupertinoUserInterfaceLevelData.base elevation level).
See also:
- resolve, which is similar to this function, but returns a
non-nullable value, and does not allow a null
resolvable
color.
Implementation
static Color? maybeResolve(Color? resolvable, BuildContext context) {
if (resolvable == null) {
return null;
}
assert(context != null);
return (resolvable is CupertinoDynamicColor)
? resolvable.resolveFrom(context)
: resolvable;
}