resolve method Null safety

Color resolve(
  1. Color resolvable,
  2. 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 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:

  • maybeResolve, which is similar to this function, but will allow a null resolvable color.

Implementation

static Color resolve(Color resolvable, BuildContext context) {
  assert(context != null);
  return (resolvable is CupertinoDynamicColor)
    ? resolvable.resolveFrom(context)
    : resolvable;
}