Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

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.


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.