Buscar pacotes, repositórios e categorias de apps

Capa de animated_theme_switcher
Detalhes do pacotev2.0.10

animated_theme_switcher

Alternador de tema animado do Flutter, que ajuda a criar transições bonitas durante a troca de tema.

AndroidiOSWebmacOSWindowsLinux
Downloads em 30 dias
2,7 mil
Curtidas
533
Pontos Pub
140

Instalar pacote

flutter pub add animated_theme_switcher

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

Um pacote Flutter que permite transições suaves e animadas ao alternar entre temas claro e escuro. Ele melhora a experiência do usuário ao fornecer mudanças de tema visualmente atraentes sem transições visuais abruptas. Projetado para desenvolvedores que desejam implementar trocas de tema elegantes com código mínimo. O pacote oferece suporte a todas as principais plataformas, incluindo Android, iOS, Web, macOS, Windows e Linux. Integra-se perfeitamente ao sistema de temas do Flutter e permite personalizar a duração da animação, curva e efeitos de transição.

Casos de uso

  • Transições suaves de tema em aplicativos móveis
  • Melhorando a UI/UX com mudanças animadas de tema
  • Implementando modo escuro com estilo visual
  • Criando design responsivo com temas dinâmicos
  • Apoiando a acessibilidade por meio de mudanças graduais no tema

Principais recursos

  • Transições de tema animadas
  • Duração e curva de animação personalizáveis
  • Compatibilidade multiplataforma
  • Integração fácil com ThemeData
  • Suporta os modos claro e escuro
  • Mínimo boilerplate necessário

Indicado para

  • Desenvolvedores de aplicativos procurando transições de UI refinadas
  • Projetos do Flutter com foco em design
  • Aplicativos com troca frequente de tema
  • Desenvolvedores priorizando a experiência do usuário
  • Projetos que exigem consistência temática em toda a plataforma

Considerações

  • Pode afetar o desempenho em dispositivos de baixa potência
  • Requer ajuste cuidadoso dos parâmetros de animação
  • Limitado a animações relacionadas ao tema apenas
  • Não adequado para mudanças de estado não temáticas
  • Depende do sistema de temas do Flutter para funcionalidade completa

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

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

Categorias

Repositório-fonte

Projetos que usam este pacote