simple_theme_switcher 0.0.3+1 copy "simple_theme_switcher: ^0.0.3+1" to clipboard
simple_theme_switcher: ^0.0.3+1 copied to clipboard

retracted

Simple light/dark mode switcher using material theme.Just wrap your App with STMaterialApp Widget and toggle it with a switch.

example/lib/main.dart

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

void main() {
  runApp(
      const STMaterialApp(debugShowCheckedModeBanner: false, child: MyApp()));
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const HomeScreen();
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // Wrap Your app with STMaterialApp instead of MaterialApp
    // Providing both STMaterialApp and MaterialApp will conflict each other and cause an error
    // Instead, just wrap your app with STMaterialApp and pass any required parameters
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.primaryContainer,
        title: Text(
          'Theme Switcher Example',
          style: TextStyle(
            color: Theme.of(context).colorScheme.onPrimaryContainer,
          ),
        ),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            // Use ThemeManager to toggle theme
            final themeManager = ThemeManager();
            themeManager.toggleTheme(
              themeManager.currentThemeMode == AppThemeMode.light
                  ? AppThemeMode.dark
                  : AppThemeMode.light,
              seedColor: Colors.yellow, // Optional seed color
            );
          },
          child: const Text('Toggle Theme'),
        ),
      ),
    );
  }
}
1
likes
0
points
157
downloads

Publisher

unverified uploader

Weekly Downloads

Simple light/dark mode switcher using material theme.Just wrap your App with STMaterialApp Widget and toggle it with a switch.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_bloc

More

Packages that depend on simple_theme_switcher