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

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

example/lib/main.dart

// Copyright © 2020 Birju Vachhani. All rights reserved.
// Use of this source code is governed by an Apache license that can be
// found in the LICENSE file.

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({super.key, this.savedThemeMode});

  @override
  State<MyApp> createState() => _MyAppState();
}

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

  @override
  Widget build(BuildContext context) {
    return AnimatedSwitcher(
      duration: const Duration(seconds: 1),
      child: isMaterial
          ? MaterialExample(
              savedThemeMode: widget.savedThemeMode,
              onChanged: () => setState(() => isMaterial = false))
          : CupertinoExample(
              savedThemeMode: widget.savedThemeMode,
              onChanged: () => setState(() => isMaterial = true)),
    );
  }
}
722
likes
0
pub points
98%
popularity

Publisher

verified publisherbirju.dev

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

Repository (GitHub)
View/report issues

Topics

#theme #theming #dynamic-theme #adaptive-theme #theme-switcher

License

unknown (LICENSE)

Dependencies

flutter, shared_preferences

More

Packages that depend on adaptive_theme