system_theme 1.0.1 copy "system_theme: ^1.0.1" to clipboard
system_theme: ^1.0.1 copied to clipboard

outdated

A plugin to get the current system theme info. Supports Android, Web and Windows

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:system_theme/system_theme.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SystemTheme.accentInstance.load();
  runApp(MaterialApp(home: MyApp()));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    SystemTheme.darkMode.then((value) {
      print(value);
    });
    print(SystemTheme.accentInstance.accent);
  }

  @override
  Widget build(BuildContext context) {
    final colors = [
      SystemTheme.accentInstance.lightest,
      SystemTheme.accentInstance.lighter,
      SystemTheme.accentInstance.light,
      SystemTheme.accentInstance.accent,
      SystemTheme.accentInstance.dark,
      SystemTheme.accentInstance.darker,
      SystemTheme.accentInstance.darkest,
    ];
    return Scaffold(
      body: Column(
        children: colors.map((color) {
          return Expanded(
            child: Container(
              color: color,
              alignment: Alignment.bottomCenter,
              padding: const EdgeInsets.symmetric(vertical: 20.0),
              child: Text(
                [
                  'Lightest',
                  'Lighter',
                  'Light',
                  'Default',
                  'Dark',
                  'Darker',
                  'Darkest',
                ][colors.indexOf(color)],
                style: Theme.of(context).textTheme.headline6?.copyWith(
                      color: color.computeLuminance() >= 0.5
                          ? Colors.black
                          : Colors.white,
                    ),
              ),
            ),
          );
        }).toList(),
      ),
    );
  }
}
83
likes
120
pub points
95%
popularity

Publisher

verified publisherbdlukaa.dev

A plugin to get the current system theme info. Supports Android, Web and Windows

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, system_theme_web

More

Packages that depend on system_theme