maybeResolve static method

Color? maybeResolve(
  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 null, returns null. If the given color is an ArnaDynamicColor, 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).

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;
  }
  return (resolvable is ArnaDynamicColor) ? resolvable.resolveFrom(context) : resolvable;
}