パッケージ、リポジトリ、アプリカテゴリを検索

animated_theme_switcher のカバー
パッケージ詳細v2.0.10

animated_theme_switcher

Flutter アニメーションテーマスイッチャー。テーマ切り替え時に美しいトランザクションを作成するのに役立ちます。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2740
いいね数
533
Pub ポイント
140

パッケージをインストール

flutter pub add animated_theme_switcher

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

ライトモードとダークモードの切り替え時にスムーズでアニメーション付きの遷移を可能にするFlutterパッケージです。急な視覚的なシフトを回避し、視覚的に魅力的なテーマ変更を提供することで、ユーザー体験を向上させます。最小限のコードで洗練されたテーマ切り替えを実装したい開発者向けに設計されています。Android、iOS、Web、macOS、Windows、Linuxなど、すべての主要プラットフォームをサポートしています。Flutterのテーマシステムとシームレスに統合され、アニメーションの持続時間、カーブ、トランジション効果をカスタマイズできます。

用途

  • モバイルアプリにおけるスムーズなテーマの切り替え
  • アニメーションテーマ変更によるUI/UXの向上
  • 視覚的な魅力を持つダークモードの実装
  • 動的テーマを使用した応答性のあるデザインの作成
  • 段階的なテーマシフトによるアクセシビリティの支援

主な機能

  • アニメーションテーマのトランジション
  • カスタマイズ可能なアニメーションの期間とカーブ
  • クロスプラットフォーム互換性
  • ThemeData との簡単な統合
  • ライトモードとダークモードの両方をサポートしています
  • 必要な最小限のボイラープレート

適している対象

  • 洗練されたUIの遷移を求めるアプリ開発者
  • デザイン重視のFlutterプロジェクト
  • テーマの切り替えが頻繁なアプリ
  • ユーザー体験を最優先にする開発者
  • プラットフォーム全体でのテーマの一貫性を必要とするプロジェクト

注意事項

  • 低スペックデバイスでのパフォーマンスに影響を与える可能性があります
  • アニメーションパラメータの微調整が必要です
  • テーマ関連のアニメーションのみに制限
  • テーマ以外の状態変更には適していません
  • 完全な機能を実現するにはFlutterのテーマシステムに依存します

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

animated_theme_switcher

Pub

Animated theme switcher.

This library starts from Peyman's stackoverflow question how-to-add-animation-for-theme-switching-in-flutter

demo

Getting started

Add animated_theme_switcher: "^2.0.8" in your pubspec.yaml dependencies.

dependencies:
 animated_theme_switcher: "^2.0.8"
How To Use

Import the following package in your dart file

import 'package:animated_theme_switcher/animated_theme_switcher.dart';

Wrap MaterialApp with ThemeProvider widget, as it has shown in the following example:

  ThemeProvider(
      initTheme: initTheme,
      builder: (context, myTheme) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: myTheme,
          home: MyHomePage(),
        );
      }),
    ),

But if all you want is to provide a theme, use as follows:

  ThemeProvider(
      initTheme: initTheme,
      child: SomeCoolPage(),
    ),

Wrap the screen where you whant to make them switch with ThemeSwitchingArea widget, as it has shown in the following example:

    ThemeSwitchingArea(
      child: Builder(builder: (context) {
        return ...,
      },
    );

Wrap every switcher with ThemeSwitcher builder, and use ThemeSwitcher.of(context).changeTheme function to switch themes;


    ThemeData newTheme = ThemeData(
      primaryColor: Colors.amber
    );
    ...
    ThemeSwitcher(
      builder: (context) {
        ...
        onTap: () => ThemeSwitcher.of(context).changeTheme(
          theme: newTheme,
          isReversed: false // default: false 
        );
        ...
      },
    );

Alternatively you could use ThemeSwitcher.switcher() or ThemeSwitcher.withTheme().
Builders of this constructors already provide you ThemeSwitcher.
ThemeSwitcher.withTheme() also provides current theme:

    ThemeSwitcher.switcher(
      builder: (context, switcher) {
        ...
        onTap: () => switcher.changeTheme(
          theme: newTheme,
        );
        ...
      },
    );
    
    ThemeSwitcher.withTheme(
      builder: (context, switcher, theme) {
        ...
        onTap: () => switcher.changeTheme(
          theme: theme.brightness == Brightness.light
              ? darkTheme
              : lightTheme,
        );
        ...
      },
    );

Use optional named parameter clipper to pass the custom clippers.

    ...
    ThemeSwitcher(
      clipper: ThemeSwitcherBoxClipper(),
      builder: (context) {
        ...
      },
    );

Notes:

  1. This package is not intended to persist selected theme on the local device. But we added special example to show how to do it using shared_preferences package.

  2. Use the CanvasKit rendering engine to use it on web, more about it..

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト