light_dark_theme_toggle 1.1.2 copy "light_dark_theme_toggle: ^1.1.2" to clipboard
light_dark_theme_toggle: ^1.1.2 copied to clipboard

An animated, customizable Flutter widget for switching between light and dark modes with a visually appealing toggle.

example/lib/main.dart

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

void main() => runApp(const MyApp());

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  bool isDarkMode = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: isDarkMode ? ThemeData.dark() : ThemeData.light(),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Light/Dark Theme Toggle Example'),
          actions: [
            Padding(
              padding: const EdgeInsets.only(right: 16.0),
              child: LightDarkThemeToggle(
                value: isDarkMode,
                onChanged: (value) {
                  setState(() {
                    isDarkMode = value;
                  });
                },
              ),
            ),
          ],
        ),
        body: Center(
          child: Wrap(
            spacing: 10,
            runSpacing: 10,
            runAlignment: WrapAlignment.center,
            alignment: WrapAlignment.center,
            children: [
              ...ThemeIconType.values.map(
                (themeIconType) {
                  return Card(
                    child: LightDarkThemeToggle(
                      size: 128.0,
                      themeIconType: themeIconType,
                      value: isDarkMode,
                      onChanged: (value) {
                        setState(() {
                          isDarkMode = value;
                        });
                      },
                    ),
                  );
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}
8
likes
150
points
123
downloads

Publisher

unverified uploader

Weekly Downloads

An animated, customizable Flutter widget for switching between light and dark modes with a visually appealing toggle.

Homepage
Repository (GitHub)
View/report issues

Topics

#theme-toggle #switch #toggle #widget #animation

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on light_dark_theme_toggle