搜索插件、代码仓与 APP 分类

animated_toggle 封面
插件详情v0.1.3

animated_toggle

Animated Toggle 让您轻松创建自定义的动画切换按钮。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
196
喜欢数
29
Pub 分数
150

安装插件

flutter pub add animated_toggle

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Animated Toggle 是一个 Flutter 包,可简化自定义动画切换开关的创建。它提供流畅且视觉上吸引人的开/关状态转换,设置简单。专为希望在不编写复杂动画代码的情况下提升 UI 交互性的开发者设计,支持 Android、iOS、Web、macOS、Windows 和 Linux 多个平台。该包轻量级,可通过简单的添加命令无缝集成到现有的 Flutter 项目中。适用于设置面板、主题切换或任何交互式开关界面。

适合场景

  • 自定义主题切换
  • 用户偏好开关
  • 设置 UI 组件
  • 入门流程指示器
  • 交互式表单元素

主要特点

  • 平滑的动画过渡
  • 可自定义外观
  • 跨平台支持
  • 最小化样板
  • 通过 pub 轻松集成
  • 可配置的切换行为

适合对象

  • 寻求交互元素的UI设计师
  • 开发人员构建设置屏幕
  • 需要视觉反馈的应用程序
  • Flutter 初学者探索动画
  • 具有跨平台需求的项目

使用建议

  • 仅限切换特定用例
  • 需要手动样式设置以实现高级设计
  • 无内置辅助功能
  • 依赖外部动画逻辑
  • 不适合复杂的状态机
  • 可能需要额外的软件包才能实现完全自定义

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Animated Toggle

Pub Pub likes Pub popularity Pub points

P1

Animated Toggle Give you easy way to make your custom Animated toggle.

Vertical Examples Horizontal Examples Default Ex

Full Ex

Installation

Add this to your pubspec.yaml:

dependencies:
  animated_toggle: ^Last Version

Features

Easy to use the Animated Toggle Package you can handle all colors and width and the height and you can make it vertical or horizontal. You can control the start from left or right if you need this for arabic or english or etc. you can control the Text Style and the padding for the Animated Toggle.

Getting started

import 'package:animated_toggle/animated_toggle.dart';

void main() {
  
}

// Start use th package in your State Widget

What you can handle

Horizontal Animated Toggle

final Duration duration;
final List<String> taps;
final double width;
final double height;
final int initialIndex;
final Color background;
final Color activeColor;
final Color inActiveColor;
final Color underLineColor;
final Color activeUnderLineColor;
final TextStyle activeTextStyle;
final TextStyle inActiveTextStyle;
final double spaceBetween;
final double horizontalPadding;
final double verticalPadding;
final double activeHorizontalPadding;
final double activeVerticalPadding;
final double radius;
final double underLineHeight;
final double activeUnderLineHeight;
final double activeButtonRadius;
final double inActiveButtonRadius;
final Function(int currentIndex, int targetIndex)? onChange;
final bool showUnderLine;
final bool showActiveButtonColor;
final String local;
final List<Widget>? prefixIcons;
final bool showPrefixIcon;
final double spaceBetweenIconAndText;
final List<BoxShadow>? activeBoxShadow;
final List<BoxShadow>? inActiveBoxShadow;
final Border? activeBorder;
final Border? inActiveBorder;

Vertical Animated Toggle

final Duration duration;
final List<String> taps;
final double width;
final double height;
final int initialIndex;
final Color background;
final Color activeColor;
final Color inActiveColor;
final Color sideLineColor;
final Color activeSideLineColor;
final TextStyle activeTextStyle;
final TextStyle inActiveTextStyle;
final double horizontalPadding;
final double verticalPadding;
final double activeHorizontalPadding;
final double activeVerticalPadding;
final double radius;
final double activeButtonHeight;
final double sideLineWidth;
final double activeSideLineWidth;
final double activeButtonRadius;
final double inActiveButtonRadius;
final Function(int currentIndex, int targetIndex)? onChange;
final bool showSideLine;
final bool showActiveButtonColor;
final String local;
final List<Widget>? prefixIcons;
final bool showPrefixIcon;
final double spaceBetweenIconAndText;
final List<BoxShadow>? activeBoxShadow;
final List<BoxShadow>? inActiveBoxShadow;
final Border? activeBorder;
final Border? inActiveBorder;

Usage

For More Examples Go To Example Tap

How to use Horizontal Animated Toggle

class MyAnimatedToggle extends StatefulWidget {
  const MyAnimatedToggle({super.key});

  @override
  State<MyAnimatedToggle> createState() => _MyAnimatedToggleState();
}

class _MyAnimatedToggleState extends State<MyAnimatedToggle> {
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Animated Toggle'),
      ),
      body: Center(
        child: AnimatedHorizontalToggle(
          taps: const ['First', 'Second', 'Last'],
          // write you taps names
          width: MediaQuery.of(context).size.width - 40,
          height: 48,
          duration: const Duration(milliseconds: 300),
          initialIndex: 0,
          background: Colors.black.withOpacity(0.1),
          activeColor: Colors.deepPurple,
          // here you can control the active text style
          activeTextStyle: const TextStyle(
              fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white),
          // here you can control the inactive text style
          inActiveTextStyle: const TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.w400,
              color: Colors.deepPurple),
          // the next 2 line if you need to put padding for the inactive buttons
          horizontalPadding: 4,
          verticalPadding: 4,
          // the next 2 line if you need to put padding for the active button
          activeHorizontalPadding: 2,
          activeVerticalPadding: 4,
          radius: 14,
          // you can control the radius for the Animated widget
          activeButtonRadius: 14,
          // you can control the radius for the active button
          onChange: (int currentIndex, int targetIndex) {
            // write Your Personal Code Here
          },
          showActiveButtonColor: true,
          // 'en' mean make the start from left other mean start from right
          local:
          'en', // her you can add the local to control the alignment like if you use en its the normal to start from left to right and if you use ar the will start from right to left
        ),
      ),
    );
  }
}

How to use Vertical Animated Toggle

class MyAnimatedToggle extends StatefulWidget {
  const MyAnimatedToggle({super.key});

  @override
  State<MyAnimatedToggle> createState() => _MyAnimatedToggleState();
}

class _MyAnimatedToggleState extends State<MyAnimatedToggle> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Animated Toggle'),
      ),
      body: Center(
        child: AnimatedVerticalToggle(
          taps: const ['First', 'Second', 'Third', 'Last'],
          width: 80,
          height: 200,
          duration: const Duration(milliseconds: 300),
          activeButtonHeight: 34,
          initialIndex: 0,
          background: Colors.black.withOpacity(0.1),
          activeColor: Colors.deepPurple,
          // here you can control the active text style
          activeTextStyle: const TextStyle(
              fontSize: 16,
              fontWeight: FontWeight.w600,
              color: Colors.white),
          // here you can control the inactive text style
          inActiveTextStyle: const TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.w400,
              color: Colors.deepPurple),
          // the next 2 line if you need to put padding for the inactive buttons
          horizontalPadding: 4,
          verticalPadding: 4,
          // the next 2 line if you need to put padding for the active button
          activeHorizontalPadding: 4,
          activeVerticalPadding: 2,
          radius: 14,
          // you can control the radius for the Animated widget
          activeButtonRadius: 10,
          // you can control the radius for the active button
          onChange: (int currentIndex, int targetIndex) {
            // write Your Personal Code Here
          },
          showActiveButtonColor: true,
          // 'en' mean make the start from left other mean start from right
          local:
          'en', // her you can add the local to control the alignment like if you use en its the normal to start from left to right and if you use ar the will start from right to left
        ),
      ),
    );
  }
}

Additional information

Say to me in GitHub what you need to see in the package in the next update. Wait for more feature soon.

Author

Loay Omar

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。