Search packages, repositories and app categories

appearance cover
Package detailsv0.0.1

appearance

Flutter package to implement Light, Dark and Sytem Theme mode, and persist it on restart of app.

AndroidiOSWeb
30-day downloads
83
Likes
5
Pub points
150

Install package

flutter pub add appearance

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The appearance package simplifies implementing light, dark, and system theme modes in Flutter applications. It provides a seamless way to switch between themes and persist the selected mode across app restarts. Built with ease of integration in mind, it handles theme state management and ensures consistent user experience across Android, iOS, and web platforms. The package supports dynamic theme switching and automatically adapts to system-level theme preferences.

Use cases

  • Implementing theme toggles in mobile and web apps
  • Persisting user's theme preference after app restart
  • Supporting system theme awareness
  • Creating accessible UI with light and dark modes
  • Enabling smooth theme transitions

Key features

  • Light, dark, and system theme support
  • Persistent theme state storage
  • Automatic system theme detection
  • Cross-platform compatibility (Android, iOS, Web)
  • Simple API for theme switching

Suitable for

  • Flutter developers building cross-platform apps
  • Apps requiring user-customizable themes
  • Projects focused on accessibility and UX
  • Developers wanting minimal boilerplate for theming
  • Applications targeting both mobile and web

Considerations

  • Requires manual handling of theme-specific widget styling
  • Does not include built-in theme design components
  • Limited to theme mode persistence, not full theme customization
  • May require additional setup for complex theme logic
  • Depends on external state management if used beyond basic functionality

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

appearance

Appearance

Flutter package that easily implement Light, Dark and System theme mode in your application and persists the theme mode on restart of the application.

🚀 Demo: Appearance

📱 Screenshots

Appearance Demo 1 Appearance Demo 2

🛠 Installation

  1. Add dependency to pubspec.yaml file:
    Get the latest version from the 'Installing' tab on pub.dev
dependencies:
  appearance: ^latest_version
  1. Import the package
import 'package:appearance/appearance.dart';

📘 How to use

  1. Initialize SharedPreferencesManager singleton for SharedPreference and add it before runApp() method.
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SharedPreferencesManager.instance.init();
  runApp(const MyApp());
}
  1. extend your root class with AppearanceState using keyword with.
class _MyAppState extends State<MyApp> with AppearanceState { }
  1. Wrap your MaterialApp or CupertinoApp with BuildWithAppearance
BuildWithAppearance(
    initial: ThemeMode.light, // optional : default value is [ThemeMode.system]
    builder: (context) => MaterialApp()
);
Using MaterialApp
BuildWithAppearance(
    initial: ThemeMode.light, // optional : default value is [ThemeMode.system]
    builder: (context) => MaterialApp(
        title: 'Appearance (Material Example)',
        themeMode: Appearance.of(context)?.mode,
        theme: ThemeData(
            brightness: Brightness.light,
        ),
        darkTheme: ThemeData(
            brightness: Brightness.dark,
        ),
        home: const HomeMaterialPage(),
    ),
);
Using CupertinoApp
BuildWithAppearance(
    initial: ThemeMode.light, // optional : default value is [ThemeMode.system]
    builder: (context) {
        return CupertinoApp(
            title: 'Appearance (Cupertino Example)',
            theme: CupertinoThemeData(
                brightness: Appearance.of(context)?.cupertinoBrightness!,
            ),
            localizationsDelegates: const [
                DefaultMaterialLocalizations.delegate,
                DefaultCupertinoLocalizations.delegate,
                DefaultWidgetsLocalizations.delegate,
            ],
            home: HomeCupertinoPage(),
        );
    },
);

🌟 Features

  • Light, Dark and System mode options to change theme of app.

  • Theme persistance: Saved theme is persisted using SharedPreferences on restart.

  • Auto Listen Theme Mode changes, without adding extra listener.

  • Material and Cupertino, both apps are supported.

🧰 Parameters

  • initial: [optional]
    Set the initial ThemeMode of the app, by default its value is ThemeMode.system

Change Theme Mode

You can use the setMode method to change the theme mode of the app.

 // sets theme mode to System
 Appearance.of(context)?.setMode(ThemeMode.system),

 // sets theme mode to Light
 Appearance.of(context)?.setMode(ThemeMode.light),

 // sets theme mode to Dark
 Appearance.of(context)?.setMode(ThemeMode.dark),

Get Theme Mode

 // get active theme mode
 Appearance.of(context)?.mode

Get Cupertino Theme brightness

 // get active cupertino theme brightness
 Appearance.of(context)?.cupertinoBrightness!,

💻 Example

Check out the example app in the example directory for both Material and Cupertino.

📝Contribution

Feel free to contribute to this project.

  • If you found a bug or have a feature request, open an issue.

  • If you want to contribute, submit a pull request.

💳 License

This project is LICENSED under the MIT License. Use it freely, but let's play nice and give credit where it's due!

🎉 Conclusion

I will be happy to answer any questions that you may have on this approach,
If you liked this package, don't forget to show some ❤️ by smashing the ⭐.

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.