FLUTTER ECOSYSTEM

fysoul17/flutter_speed_dial_material_design

用於實現 Material Design 速度撥號的 Flutter 外掛程式(https://material.io/components/buttons-floating-action-button/#types-of-transitions)

flutter_speed_dial_material_design 專案封面
Stars
30
Forks
9
最近推送(UTC)
2020年12月26日
專案狀態
未封存
Terry K GitHub avatar
GITHUB User

Terry K ↗

Entrepreneurial CTO shipping world-class products in AI, Web3, and Gaming.

EarthAustralia / South Korea
語言DartKotlinSwiftObjective-C

此儲存庫發佈的套件

使用的依賴

依賴清單 2 項
  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

Flutter Speed dial of Material Design style

Flutter package which applies Material design Speed dial

Preview

There are several packages that provide fancy speed dial. However, as most of those do not work properly on docked FAB using notch, I referenced Andrea Bizzoto and Matt Carroll's idea/code specified here to make it work fine with notch as well. Truly appreciate to Andrea and Matt for sharing such an awesome idea and codes.

https://raw.githubusercontent.com/fysoul17/flutter_speed_dial_material_design/HEAD/screenshots/sample_screen.gif

Usage

Basic usage
Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(child: _buildBody()),
      floatingActionButton: _buildFloatingActionButton(),
      floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
      bottomNavigationBar: _buildBottomBar(),
    );
  }

Widget _buildFloatingActionButton() {
    final icons = [
      SpeedDialAction(child: Icon(Icons.mode_edit)),
      SpeedDialAction(child: Icon(Icons.date_range)),
      SpeedDialAction(child: Icon(Icons.list)),
    ];

    return SpeedDialFloatingActionButton(
      actions: icons,
      // Make sure one of child widget has Key value to have fade transition if widgets are same type.
      childOnFold: Icon(Icons.event_note, Key: UniqueKey()),
      childOnUnfold: Icon(Icons.add),
      useRotateAnimation: true,
      onAction: _onSpeedDialAction,
    );
  }
  
_onSpeedDialAction(int selectedActionIndex) {
  print('$selectedActionIndex Selected');
}
Using controller
SpeedDialController _controller = SpeedDialController();

SpeedDialFloatingActionButton(
      controller: _controller,
      ...
    );
    
// Use anywhere to mannually unfold
_controller.unfold();
Fade Transition animation between child widgets

In order to apply fade transition between [childOnFold] and [childOnUnfold], make sure one of those has Key field. (eg. ValueKey(value) or UniqueKey()). As we using AnimatedSwitcher for transition animation, no key with same type of child will perform no animation. It is AnimatedSwitcher's behaviour.

TO-DOs

  • [ ] Ability to display/hide speed dial when it is needed. (ex. hiding on scroll)
  • [X] Unfold function to force close the dial
  • [ ] Providing option for modal background with color parameter
  • [X] Text labels on each action widgets (Thanks to @CarlosHJuniior)

Contributing

Any pull requests for implementing To-Do functions are always welcome!

Other useful packages you might be instrested

Firebase Auth Simplify Google Maps Place Picker

Support

If the package was useful or saved your time, please do not hesitate to buy me a cup of coffee! ;)
The more caffeine I get, the more useful projects I can make in the future.

Buy Me A Coffee