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

advanced_icon 封面
插件详情v0.1.2

advanced_icon

一个包含一系列图标装饰工具(如渐变、不透明度)和带有酷炫动画效果的图标过渡功能的 Flutter 包。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
90
喜欢数
95
Pub 分数
150

安装插件

flutter pub add advanced_icon

插件介绍

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

AdvancedIcon 是一个 Flutter 包,通过渐变和不透明度控制等装饰工具提供增强的图标自定义功能,并支持图标过渡的平滑动画效果。它使开发者能够在多个平台上创建具有动态行为的视觉丰富的图标。适用于需要精致 UI 元素且带有微妙但显著动画的应用程序。该包支持 Android、iOS、Web、macOS、Windows 和 Linux,使其在跨平台开发中非常灵活。其直观的 API 简化了高级视觉效果的集成,无需复杂的代码。

适合场景

  • 动画图标过渡
  • 渐变填充图标
  • 透明度控制的图标效果
  • 增强的UI微交互
  • 跨平台图标样式
  • 应用界面中的视觉反馈

主要特点

  • 渐变图标装饰
  • 不透明度调整工具
  • 平滑过渡动画
  • 跨平台兼容性
  • 简单的 API 集成
  • 可自定义的动画效果

适合对象

  • 寻求视觉精致的UI设计师
  • 开发交互式应用的开发者
  • 跨平台移动和Web项目
  • 需要引人入胜的微交互的应用程序
  • 专注于美学用户体验的团队

使用建议

  • 可能会略微增加包大小
  • 需要理解动画原理
  • 仅限图标特定的增强功能
  • 最适合现代、注重设计的应用程序
  • 对低端设备的性能影响
  • 不适用于非图标用户界面组件

原始 README

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

Advanced Icon

A flutter package that contains a collection of icon decoration tools (i.e. gradient, opacity) and icon transition features with cool animation effects. See live example.

Pub Version Build Status MIT License codecov CodeFactor

Installing

With flutter run this command

flutter pub add advanced_icon

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  advanced_icon: <latest version>

Now in your Dart code, you can use:

import 'package:advanced_icon/advanced_icon.dart';

Features at a Glance

  1. An optional secondaryIcon property is available to enhance user interaction with minimal manual effort.
  2. Cool animation effects are available to make a smooth transition between icon and secondaryIcon.
  3. In addition to color, icons can also be painted with a gradient.
  4. Opacity property is available to make opaque icons.
  5. Inherits all properties of material designed Icon widget.

Icon Transition

To use the icon transition feature, secondaryIcon must not be null and when it is not null the widget will lookup for state and will show icons according to the current state. To change the icon from icon to secondaryIcon or vice-versa, let's first see about state of AdvancedIcon:

state holds the information about the current state of AdvancedIcon. AdvancedIcon can have any one of the following states:

  1. AdvancedIconState.primary
  2. AdvancedIconState.secondary

Whenever the state changes, it notifies AdvancedIcon and AdvancedIcon changes the current icon following the below rules:

  1. icon will appear for AdvancedIconState.primary.
  2. secondaryIcon will appear for AdvancedIconState.secondary.

state can be changed using any of the following methods:

  • setState
  • provider
  • stream
  • inheritedWidget
  • or any other methods used for state management in flutter.

Let's illustrate state management of AdvancedIcon using setState. First, create a stateful widget. In the private class of the widget, define a property that holds the current state of AdvancedIcon and define a function to change the current state on every user interaction as follows:

AdvancedIconState _state = AdvancedIconState.primary;

void _changeState(){
  setState(() {
    if (_state == AdvancedIconState.primary) {
      _state = AdvancedIconState.secondary;
    } else {
      _state == AdvancedIconState.primary;
    }
  });
}

Then add a GestureDetector or IconButton inside build method and use AdvancedIcon as follows:

GestureDetector(
  onTap: _changeState,
  child: AdvancedIcon(
    icon: Icons.add, //change this icon as per your requirement.
    secondaryIcon: Icons.check, //change this icon as per your requirement.
    state: _state,
  ),
)

In above case when first time _changeState will be called, state will change to AdvancedIconState.secondary and transition will happen from Icons.add to Icons.check following the default bubble animation effect in 300ms.

Let's configure it further. There are seven cool transition effects available for icon transition features.

  1. spin
  2. bubble
  3. fade
  4. flipH
  5. flipV
  6. spinBubble
  7. bubbleFade
  8. none

Change effect property to try more animation effects as follows:

AdvancedIcon(
  icon: Icons.add, //change this icon as per your requirement.
  secondaryIcon: Icons.check, //change this icon as per your requirement.
  state: _state,
  effect: AdvancedIconEffect.spin, //change effect as per your requirement.
)

To increase or decrease the transition time, change duration property as follows:

AdvancedIcon(
  icon: Icons.add, //change this icon as per your requirement.
  secondaryIcon: Icons.check, //change this icon as per your requirement.
  state: _state,
  duration: Duration(milliseconds: 700),
  effect: AdvancedIconEffect.fade,
)

Give secondaryIcon a more specific color by setting secondaryColor property as follows:

AdvancedIcon(
  icon: Icons.add, //change this icon as per your requirement.
  secondaryIcon: Icons.check, //change this icon as per your requirement.
  color: Colors.blue, //color of primary icon, change it as per your requirement
  secondaryColor: Colors.green, //color of secondary icon, change it as per your requirement
  effect: AdvancedIconEffect.fade,
  state: _state,
)

To get better understanding, see live example.

Decoration

Gradient

To make icons look more appealing, use gradient to paint the icons. color and secondaryColor will be ignored if gradient is set as follows:

AdvancedIcon(
  icon: Icons.photo_camera,
  color: Colors.red, //color will have no effect
  gradient: const LinearGradient( //change gradient as per your requirement
    colors: <Color>[Colors.red, Colors.white],
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
    step: [0.2,0.8],
  ),
)
Opacity

Make opaque icons by setting opacity as follows:

AdvancedIcon(
  icon: Icons.direction_bike,
  color: Colors.red,
  opacity: 0.5, //should be between 0 and 1 inclusive
)

Decoration banner

Changelog

Please see the changelog to know about the latest updates.

Contributions

Contribution to this project are most welcomed.

If you find bugs or want more features, but don't know how to fix/implement them, please fill an issue.

If you fixed bugs or implemented new features, please send a pull request.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。