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

light_dark_theme_toggle 표지
패키지 상세v1.1.2

light_dark_theme_toggle

시각적으로 매력적인 토글과 함께 밝은 모드와 어두운 모드 사이를 전환할 수 있는 애니메이션 및 사용자 정의 가능한 Flutter 위젯입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
184
좋아요
16
Pub 점수
160

패키지 설치

flutter pub add light_dark_theme_toggle

패키지 개요

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

시각적으로 매력적이고 애니메이션 효과가 있는 플러터 위젯으로 밝은 테마와 어두운 테마 간의 원활한 전환을 가능하게 합니다. 사용자 맞춤설정을 고려하여 부드러운 전환과 현대적인 토글 인터페이스를 제공하며, 테마 설정이 필요한 모든 앱에 적합합니다. 이 패키지는 여러 플랫폼을 지원하고 기존 프로젝트에 쉽게 통합할 수 있습니다. 최소한의 설정으로 사용자 경험을 향상시키고 직관적인 테마 제어를 제공합니다.

사용 사례

  • 앱 테마 선호 설정
  • 동적 조명 모드를 갖춘 사용자 인터페이스
  • 테마 전환을 통한 접근성 향상
  • 개발자를 위한 사용자 정의 가능한 UI 컴포넌트
  • 크로스 플랫폼 테마 전환

주요 기능

  • 애니메이션 테마 전환
  • 매우 사용자 정의 가능한 외관
  • 모든 주요 플랫폼을 지원합니다
  • Flutter 앱과의 간단한 통합
  • 경량이고 성능이 뛰어남

적합한 대상

  • 테마 옵션을 갖춘 앱을 개발하는 개발자
  • 정교한 UI 요소를 찾는 디자이너
  • 반응형 다크/라이트 모드가 필요한 프로젝트
  • 다양한 사용자 선호를 타겟으로 하는 앱
  • 다중 플랫폼 모바일 및 웹 애플리케이션

고려 사항

  • 테마 상태 유지에 대한 수동 처리가 필요합니다
  • 기본 토글 기능에 제한됨
  • 시스템 테마 감지에 내장된 지원 없음
  • 사용자 정의 스타일링에는 추가 코드가 필요할 수 있습니다
  • 외부 테마 관리 로직에 의존합니다

원본 README

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

LightDarkThemeToggle

The LightDarkThemeToggle widget is a customizable and animated light/dark theme toggle switch for Flutter apps. It provides a visually appealing way for users to switch between light and dark modes in your app.

Features

  • Customizable size, color, padding, and tooltip.
  • Smooth animations with adjustable duration and curves.
  • Multiple animated icon styles using different theme icon types.
  • Built entirely with Dart code and CustomPainter for efficient rendering and better performance.

Demo

LightDarkThemeToggle Web App

Preview

LightDarkThemeToggle Demo


Installation

  1. Add the dependency to your pubspec.yaml:
dependencies:
  light_dark_theme_toggle: ^1.1.2
  1. Import the package in your Dart file:
import 'package:light_dark_theme_toggle/light_dark_theme_toggle.dart';

Usage

Here is an example of how to use the LightDarkThemeToggle widget:

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      themeMode: ThemeMode.system,
      home: Scaffold(
        appBar: AppBar(title: Text('Light/Dark Theme Toggle')),
        body: Center(
          child: LightDarkThemeToggle(
            value: false,
            // Initial value (false for dark, true for light)
            onChanged: (bool value) {
              // Handle theme change here.
            },
            size: 48.0,
            themeIconType: ThemeIconType.expand,
            color: Colors.orange,
            tooltip: 'Toggle Theme',
            duration: Duration(milliseconds: 500),
            curve: Curves.easeInOut,
          ),
        ),
      ),
    );
  }
}

Properties

Property Type Default Description
value bool Required Determines whether the toggle is in light (true) or dark (false) mode.
onChanged ValueChanged<bool> Required Callback when the toggle is pressed.
themeIconType ThemeIconType ThemeIconType.expand Defines the style of the icon.
color Color? ThemeData.colorScheme.onSurface Color of the icon.
hoverColor Color? ThemeData.hoverColor Hover Color of the toggle.
highlightColor Color? ThemeData.highlightColor Highlight Color of the toggle in pressed down state.
focusColor Color? ThemeData.focusColor Focus Color of the toggle when it has input focus.
splashColor Color? ThemeData.splashColor Splash Color of the toggle.
tooltip String? null Tooltip displayed on long press or hover.
padding EdgeInsetsGeometry? null Padding around the icon.
size double? IconTheme.size ?? 24.0 Size of the icon.
duration Duration Duration(milliseconds: 500) Duration of the animation.
reverseDuration Duration Duration(milliseconds: 500) Duration of the reverse animation.
curve Curve Curves.easeOutBack Animation curve for the forward animation.
reverseCurve Curve Curves.easeOutBack Animation curve for the reverse animation.

Theme Icon Types

The widget supports the following icon types via the ThemeIconType enum:

  • Classic
  • Simple
  • Eclipse
  • HalfSun
  • DarkSide
  • InnerMoon
  • Expand
  • DarkInner

To use an icon type, pass it to the themeIconType property. For example:

LightDarkThemeToggle(
  themeIconType:ThemeIconType.eclipse,
  ...
)

Customization

Animation

You can adjust the animation by changing:

  • duration: Duration of the forward animation.
  • reverseDuration: Duration of the reverse animation.
  • curve: Curve for forward animation.
  • reverseCurve: Curve for reverse animation.
Appearance

You can customize the icon's:

  • size: Adjust the size of the toggle.
  • padding: Add padding around the icon.
  • tooltip: Set a tooltip message for accessibility.
  • color: Change the icon's color.
  • hoverColor: Change the toggle's color in hovering state.
  • focusColor: Change the toggle's color when it has the input focus.
  • highlightColor: Change the toggle's color in pressed down state.
  • splashColor: Change the toggle's splash color.

License

This project is licensed under the MIT License.


Contributions

Contributions, issues, and feature requests are welcome! Feel free to check out the issues page.


Author

Vivek Chib


Acknowledgments

This package is inspired by toggles.dev created by Alfie Jones.
Special thanks for providing inspiration and ideas that helped shape this package.

카테고리

소스 저장소

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

아직 데이터가 없습니다.