SystemColor class final

A color specified in the operating system UI color palette.

As of the current release, system colors are supported on web only. To check if the current platform supports system colors, use the static platformProvidesSystemColors field. If the field is false, other functions in this class will throw UnsupportedError.

This class is typically used in conjunction with AccessibilityFeatures.highContrast. In particular, on Windows, when a user enables high-contrast mode, they may also pick specific colors that should be used by application user interfaces. While it is common for applications to use custom color themes and design languages, in high-contrast mode it is recommended that widgets use system-specified colors to make content more legible for users.

The "light" system colors are available through SystemColor.light, and the "dark" system colors are available through SystemColor.dark.

Example:

import 'dart:ui';

Color getSystemAccentColor() {
  Color? systemAccentColor;
  if (SystemColor.platformProvidesSystemColors) {
    if (PlatformDispatcher.instance.platformBrightness == Brightness.light) {
      systemAccentColor = SystemColor.light.accentColor.value;
    } else {
      systemAccentColor = SystemColor.dark.accentColor.value;
    }
  }

  return systemAccentColor ?? const Color(0xFF007AFF);
}

See also:

Constructors

SystemColor({required String name, Color? value})
Creates an instance of a system color.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
isSupported bool
Returns true if the current platform provides the system color with the given name.
no setter
name String
Standard system color name, as defined by W3C CSS specification.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value Color?
The color value used for the color named name, if supported.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

dark SystemColorPalette
A palette of system colors for dark mode.
final
light SystemColorPalette
A palette of system colors for light mode.
final
platformProvidesSystemColors bool
Returns true if the current platform provides system colors.
no setter