패키지, 저장소 및 앱 카테고리 검색

appearance 표지
패키지 상세v0.0.1

appearance

라이트, 다크 및 시스템 테마 모드를 구현하고 앱 재시작 시 설정을 유지하는 Flutter 패키지입니다.

AndroidiOSWeb
30일 다운로드
83
좋아요
5
Pub 점수
150

패키지 설치

flutter pub add appearance

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

외관 패키지는 Flutter 애플리케이션에서 라이트 모드, 다크 모드 및 시스템 테마 모드를 구현하는 것을 간소화합니다. 주제 간 전환을 원활하게 하고 앱 재시작 후에도 선택된 모드를 유지할 수 있습니다. 통합의 용이성을 고려하여 설계되었으며, 테마 상태 관리를 처리하고 안드로이드, iOS 및 웹 플랫폼에서 일관된 사용자 경험을 보장합니다. 이 패키지는 동적 테마 전환을 지원하며 시스템 수준의 테마 설정에 자동으로 적응합니다.

사용 사례

  • 모바일 및 웹 앱에서 테마 전환 구현
  • 앱 재시작 후 사용자 테마 선호도 유지
  • 시스템 테마 인식 지원
  • 라이트 모드와 다크 모드를 갖춘 접근성 있는 UI 만들기
  • 부드러운 테마 전환 활성화

주요 기능

  • 라이트, 다크 및 시스템 테마 지원
  • 지속적인 테마 상태 저장
  • 자동 시스템 테마 감지
  • 크로스 플랫폼 호환성 (Android, iOS, Web)
  • 테마 전환을 위한 간단한 API

적합한 대상

  • 크로스 플랫폼 앱을 구축하는 Flutter 개발자
  • 사용자 맞춤형 테마가 필요한 앱
  • 접근성과 사용자 경험에 중점을 둔 프로젝트
  • 테마화를 위한 최소한의 보일러플레이트를 원하는 개발자
  • 모바일 및 웹 양쪽을 대상으로 하는 애플리케이션

고려 사항

  • 테마별 위젯 스타일링을 수동으로 처리해야 합니다
  • 내장된 테마 디자인 구성 요소를 포함하지 않음
  • 테마 모드 지속성에만 제한됨, 전체 테마 사용자 정의는 아님
  • 복잡한 테마 로직을 위해 추가 설정이 필요할 수 있습니다
  • 기본 기능을 초과하여 사용할 경우 외부 상태 관리에 의존합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

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 ⭐.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.