system_accent_color 0.0.2 copy "system_accent_color: ^0.0.2" to clipboard
system_accent_color: ^0.0.2 copied to clipboard

Retrieves the system's accent color

system_accent_color #

A Flutter plugin to retrieve the current system accent color.

Supported platforms #

Works best on desktop platforms. iOS is unsupported. Web support is not guaranteed and typically works more reliably when the Flutter web app is installed as a browser app (PWA).

Platform Source / API Notes
Linux org.freedesktop.appearance/accent-color via XDG Desktop Portal (org.freedesktop.portal.Settings) Independent of GTK theme values such as @theme_selected_bg_color
macOS NSColor.controlAccentColor
Windows DwmGetColorizationColor
Android android.R.attr.colorAccent Version/OEM dependent. Android 12+ typically reflects user-selected system accent color
iOS Not supported Always returns null
Web CSS AccentColor via temporary DOM element + computed style Better support in PWA mode. Behavior varies by browser

Usage #

import 'package:system_accent_color/system_accent_color.dart';

final Color? accentColor = await SystemAccentColor().getAccentColor();

Example #

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final accentColor = await SystemAccentColor().getAccentColor();
  runApp(MainApp(accentColor: accentColor));
}

class MainApp(final Color? _accentColor) extends StatelessWidget {
  static const Color _fallbackColor = Colors.redAccent;

  @override
  Widget build(BuildContext context) {
    final seed = accentColor ?? _fallbackColor;

    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: seed,
          brightness: Brightness.light,
        ),
      ),
      home: ...,
    );
  }
}