분류, 패키지 및 저장소 검색

패키지 상세v1.0.1

dynamic_theme

런타임 중 테마를 변경하고 재시작 간에 밝기 설정을 유지합니다

30일 다운로드
875
좋아요
136
Pub 점수
40

패키지 설치

flutter pub add dynamic_theme

패키지 개요

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

Dynamic Theme는 런타임 테마 전환을 가능하게 하는 Flutter 패키지로, 사용자가 밝은 모드와 어두운 모드를 원활하게 전환할 수 있도록 합니다. 앱 재시작 후에도 밝기 설정을 자동으로 유지하여 일관된 사용자 경험을 보장합니다. MaterialApp과 쉽게 통합되며, 동적으로 테마를 업데이트할 수 있는 간단한 API를 제공합니다. 전체 재빌드 없이 사용자 정의 가능한 외관 옵션을 제공하고자 하는 앱에 적합합니다.

사용 사례

  • 런타임 테마 전환
  • 재시작 후 사용자 설정 유지
  • 모바일 앱에서 다크 모드 지원
  • 실시간으로 UI 외관 맞춤 설정
  • 테마 유연성을 통한 접근성 향상

주요 기능

  • 실시간 테마 업데이트
  • 자동 밝기 유지
  • MaterialApp과의 간단한 통합
  • 라이트 모드 및 다크 모드 지원
  • 최소한의 보일러플레이트 코드

적합한 대상

  • 동적 테마가 필요한 앱
  • 사용자 경험을 우선시하는 개발자
  • 다크 모드를 지원하는 프로젝트
  • 크로스 플랫폼 모바일 애플리케이션
  • 사용자 정의 가능한 UI를 가진 앱

고려 사항

  • 밝기 및 테마 변경만 가능
  • 내장된 것 외에 사용자 지정 테마 유형에 대한 지원 없음
  • 테마별 자산을 수동으로 처리해야 합니다
  • 복잡한 테마 시스템에 적합하지 않습니다
  • 완전한 기능을 위해 MaterialApp에 의존합니다

원본 README

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

dynamic_theme

Dynamically changing your theme without hassle

This packages manages changing your theme during runtime and persiting that theme.

I wrote a medium post about this, check it out here!

Include in your project

dependencies:
  dynamic_theme: ^1.0.1

run packages get and import it

import 'package:dynamic_theme/dynamic_theme.dart';

if you want the dialog:

import 'package:dynamic_theme/theme_switcher_widgets.dart';

Usage

Wrap your material app like this:


class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new DynamicTheme(
      defaultBrightness: Brightness.light,
      data: (brightness) => new ThemeData(
        primarySwatch: Colors.indigo,
        brightness: brightness,
      ),
      themedWidgetBuilder: (context, theme) {
        return new MaterialApp(
          title: 'Flutter Demo',
          theme: theme,
          home: new MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    );
  }
}

Change the theme like this:

  void changeBrightness() {
    DynamicTheme.of(context).setBrightness(Theme.of(context).brightness == Brightness.dark? Brightness.light: Brightness.dark);
  }
  
  void changeColor() {
    DynamicTheme.of(context).setThemeData(new ThemeData(
        primaryColor: Theme.of(context).primaryColor == Colors.indigo? Colors.red: Colors.indigo
    ));
  }

When changing the brightness with setBrightness, it is additionally stored in the shared preferences.

Also included

A dialog widget to change the brightness!

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.