getColor static method

Color? getColor({
  1. required Brightness? brightness,
  2. required Color light,
  3. required Color dark,
  4. BuildContext? context,
  5. Color? color,
  6. bool nullable = false,
})

nullable 可为空 color 默认颜色

Implementation

static Color? getColor({
  required Brightness? brightness,
  required Color light,
  required Color dark,
  BuildContext? context,
  Color? color,
  bool nullable = false,
}) {
  if (!enableDark) return light;

  if (color != null) return color;
  if (brightness == null && nullable) return null;
  var _bright = brightness ??
      (context == null ? platformBrightness : Theme.of(context).brightness);
  var isLight = _bright == Brightness.light;
  var _color = isLight ? light : dark;
  return _color;
}