Adaptive Chameleon Theme는 라이트, 다크, 시스템 테마 모드를 지원함으로써 테마 관리를 간소화하는 플러터 패키지입니다. 사용자 선호 또는 시스템 설정에 따라 동적으로 색상 전환을 가능하게 하여 다양한 기기에서 일관되고 적응형 UI를 보장합니다. Flutter의 ThemeData와 원활하게 통합되며, 테마 모드 감지 및 색상 커스터마이징을 위한 사용하기 쉬운 유틸리티를 제공합니다. 반응형 디자인과 접근성 요구가 있는 앱에 이상적이며, 자동 테마 적응을 통해 사용자 경험을 향상시킵니다.
사용 사례
모바일 앱에서의 동적 테마 전환
다크 모드 및 시스템 테마 지원
테마별 앱 색상 맞춤 설정
접근성 있는 UI 구축
다중 플랫폼 테마 일관성
주요 기능
라이트, 다크 및 시스템 테마 모드 지원
간편한 색상 테마 전환
자동 시스템 테마 감지
크로스 플랫폼 호환성
ThemeData와의 간단한 통합
사용자 정의 테마 변수
적합한 대상
반응형 Flutter 앱을 개발하는 개발자
다중 플랫폼을 대상으로 하는 앱
접근성 기능이 필요한 프로젝트
사용자 경험에 중점을 둔 팀
다양한 테마를 가진 디자인 시스템
고려 사항
테마 색상 수동 구성 필요
기본 테마 모드 처리에 제한됨
사용자 설정에 대한 내장된 지속성 없음
ThemeData의 올바른 구현에 의존함
고급 테마를 사용하려면 추가 패키지가 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Adaptive Chameleon Theme
A Flutter package that will automatically retrieve your OS defined Theme (Dynamic), force your
prefered one (Light / Dark), allow you to present the user with a set of color themes to choose
from and of course, persist this choice in your device.
Features
Set default theme
Override system theme mode and set yours (light/dark)
Change theme colors
Customize color palettes for different theme modes
This package allows for an arbitrary number of themes to be defined. Each theme has a unique ID
of type int. To create the themes and map them to IDs, first you have to create an instance of
ThemeCollection, like so:
final themeCollection = ThemeCollection(
themes: {
0: ThemeData(primarySwatch: Colors.blue),
1: ThemeData(primarySwatch: Colors.red),
},
fallbackTheme: ThemeData.light(), // optional fallback theme, default value is ThemeData.light()
);
I would however recommend you introduce a class with static const int values to
associate a name to each ID value for easier reference:
You can utilise the changeThemeMode function from anywhere in your app. It provides a simple
and
straight forward way of altering the theme modes: light to dark, dark to light or to system
default.
This function has two optional parameters: dynamic and dark.
If the value of dynamic is true, it takes precedence over dark.
// sets theme mode to darkAdaptiveChameleonTheme.of(context).changeThemeMode(dark: true);
// sets theme mode to lightAdaptiveChameleonTheme.of(context).changeThemeMode(dark: false);
// sets theme mode to system defaultAdaptiveChameleonTheme.of(context).changeThemeMode(dynamic: true);
Changing Theme Color
The theme can be set anywhere in the app, provided you have a BuildContext, e.g.:
By setting the theme, its ID is automatically saved via the shared_preferences package, so the next time the
app starts, the theme can be restored automatically.
The example app can be found in the example folder. It implements a dropdown menu to select
between 5 themes. The app is the source for the video demo above.
Showcase
Using this package in a live app? Let me know and I will add it here.