项目作者: Frezyx

项目描述 :
Flutter package to create custom animated IconButton. Includes all available Icons.
高级语言: Dart
项目地址: git://github.com/Frezyx/animated_icon_button.git
创建时间: 2020-07-17T09:10:06Z
项目社区:https://github.com/Frezyx/animated_icon_button

开源协议:MIT License

下载


animated_icon_button

😊 Flutter package to create custom animated IconButton.


😵 Includes all available icons. Based on native IconButton.











Breaking Change

After 1.0.2 version you can use multiple icons.

Getting Started

Follow these steps to use this library

Add dependency

  1. dependencies:
  2. animated_icon_button: ^1.0.2 #latest version

Add import package

  1. import 'package:animated_icon_button/animated_icon_button.dart';

Easy to use

Simple example of use AnimatedIconButton

Put this code in your project at an screen and wait for magic 😊

  1. AnimatedIconButton(
  2. onPressed: () => print('all icons pressed'),
  3. icons: [
  4. AnimatedIconButtonEntry(
  5. icon: Icon(Icons.add),
  6. onPressed: () => print('add pressed'),
  7. ),
  8. AnimatedIconButtonEntry(
  9. icon: Icon(Icons.close),
  10. ),
  11. ],
  12. ),

More icons

Now you can use more than 2 icons
Add new icons to your list and they will change one by one

  1. AnimatedIconButton(
  2. size: 35,
  3. onPressed: () {
  4. print('all icons pressed');
  5. },
  6. duration: const Duration(milliseconds: 200),
  7. icons: <AnimatedIconButtonEntry>[
  8. AnimatedIconButtonEntry(
  9. icon: Icon(
  10. Icons.mic,
  11. color: Colors.purple,
  12. ),
  13. onPressed: () => print('mic pressed'),
  14. backgroundColor: Colors.white,
  15. ),
  16. AnimatedIconButtonEntry(
  17. icon: Icon(
  18. Icons.g_translate,
  19. color: Colors.purple,
  20. ),
  21. backgroundColor: Colors.white,
  22. ),
  23. AnimatedIconButtonEntry(
  24. icon: Icon(
  25. Icons.collections_sharp,
  26. color: Colors.purple,
  27. ),
  28. backgroundColor: Colors.white,
  29. ),
  30. ],
  31. ),

Custom animation controller

In order to animate your icons in a custom way, like on text changed or when pressing a button, just use the animationController property as follows.

  1. var animationController = AnimationController(
  2. vsync: this,
  3. duration: Duration(milliseconds: 200),
  4. reverseDuration: Duration(milliseconds: 200),
  5. );
  6. AnimatedIconButton(
  7. animationController: animationController,
  8. size: 35,
  9. onPressed: () {
  10. print('all icons pressed');
  11. },
  12. duration: const Duration(milliseconds: 200),
  13. icons: <AnimatedIconButtonEntry>[
  14. AnimatedIconButtonEntry(
  15. icon: Icon(
  16. Icons.mic,
  17. color: Colors.purple,
  18. ),
  19. onPressed: () => print('mic pressed'),
  20. backgroundColor: Colors.white,
  21. ),
  22. AnimatedIconButtonEntry(
  23. icon: Icon(
  24. Icons.g_translate,
  25. color: Colors.purple,
  26. ),
  27. backgroundColor: Colors.white,
  28. ),
  29. AnimatedIconButtonEntry(
  30. icon: Icon(
  31. Icons.collections_sharp,
  32. color: Colors.purple,
  33. ),
  34. backgroundColor: Colors.white,
  35. ),
  36. ],
  37. ),

Then, whenever you want, execute your animationController.forward() and animationController.reverse() methods to get your icons animated.

Don’t forget when you use this property duration is not used, so it can be emitted.