adaptive_theme 2.3.1 copy "adaptive_theme: ^2.3.1" to clipboard
adaptive_theme: ^2.3.1 copied to clipboard

Allows to change between light and dark theme dynamically and add system adaptive theme support.

example/lib/main.dart

import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:example/cupertino_example.dart';
import 'package:example/material_example.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final savedThemeMode = await AdaptiveTheme.getThemeMode();
  runApp(MyApp(savedThemeMode: savedThemeMode));
}

class MyApp extends StatefulWidget {
  final AdaptiveThemeMode? savedThemeMode;

  const MyApp({Key? key, this.savedThemeMode}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool isMaterial = true;

  @override
  Widget build(BuildContext context) {
    return AnimatedSwitcher(
      duration: Duration(seconds: 1),
      child: isMaterial
          ? MaterialExample(
              savedThemeMode: widget.savedThemeMode,
              onChanged: () => setState(() => isMaterial = false))
          : CupertinoExample(
              savedThemeMode: widget.savedThemeMode,
              onChanged: () => setState(() => isMaterial = true)),
    );
  }
}
947
likes
140
points
18.1k
downloads

Documentation

API reference

Publisher

verified publisherbirju.dev

Weekly Downloads

Allows to change between light and dark theme dynamically and add system adaptive theme support.

Repository (GitHub)
View/report issues
Contributing

License

Apache-2.0 (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on adaptive_theme