flutter_speed_dial_material_design 2.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

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.

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

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

[2.0.0] - 26/May/2020 #

  • Feature added. There are now several new properties available. (by @wbsantos). Colors, Label Position and Screen color overlay

[1.2.0] - 01/Apr/2020 #

  • Feature added. Text labels on each action widgets (by @CarlosHJuniior).

[1.1.1] - 24/Jan/2020 #

  • Updated README

[1.1.0] - 24/Jan/2020 #

  • Added SpeedDialController with unfold() function. You can now unfold manually using the controller.

[1.0.6] - 07/Dec/2019 #

  • Bug Fix: useRotation parameter is working correctly now for single child FAB

[1.0.5] - 06/Dec/2019 #

  • Runnable example updated
  • Comments added regarding fade transition animation for child widgets of FAB

[1.0.4] - 05/Dec/2019 #

  • Fixed wrong example gif
  • Changed unfold icon on example

[1.0.3] - 05/Dec/2019 #

  • Code format using 'flutter format'
  • Update description

[1.0.0] - 05/Dec/2019 #

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_speed_dial_material_design/flutter_speed_dial_material_design.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark(),
      home: MyPage(),
    );
  }
}

class MyPage extends StatefulWidget {
  @override
  _MyPageState createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> {
  SpeedDialController _controller = SpeedDialController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('FAB with Speed dial Sample'),
            RaisedButton(
              child: Text("Unfold FAB"),
              onPressed: () {
                _controller.unfold();
              },
            )
          ],
        ),
      ),
      floatingActionButton: _buildFloatingActionButton(),
      floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
      bottomNavigationBar: _buildBottomBar(),
    );
  }

  Widget _buildFloatingActionButton() {
    final TextStyle customStyle = TextStyle(inherit: false, color: Colors.black);
    final icons = [ 
      SpeedDialAction(
        //backgroundColor: Colors.green, 
        //foregroundColor: Colors.yellow, 
        child: Icon(Icons.mode_edit), 
        label: Text('Edit any item', style: customStyle)),
      SpeedDialAction(child: Icon(Icons.date_range), label: Text('Choose the date', style: customStyle)),
      SpeedDialAction(child: Icon(Icons.list), label: Text('Menu', style: customStyle)),
    ];

    return SpeedDialFloatingActionButton(
      actions: icons,
      childOnFold: Icon(Icons.event_note, key: UniqueKey()),
      screenColor: Colors.black.withOpacity(0.3),
      //childOnUnfold: Icon(Icons.add),
      useRotateAnimation: false,
      onAction: _onSpeedDialAction,
      controller: _controller,
      isDismissible: true,
      //backgroundColor: Colors.yellow,
      //foregroundColor: Colors.blue,
    );
  }

  _onSpeedDialAction(int selectedActionIndex) {
    print('$selectedActionIndex Selected');
  }

  Widget _buildBottomBar() {
    return BottomAppBar(
      shape: CircularNotchedRectangle(),
      notchMargin: 4.0,
      child: Container(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          children: <Widget>[
            IconButton(
              icon: Icon(Icons.menu),
              onPressed: () => {},
            ),
            IconButton(
              icon: Icon(Icons.today),
              onPressed: () => {},
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_speed_dial_material_design: ^2.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_speed_dial_material_design/flutter_speed_dial_material_design.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Jul 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package not compatible with SDK dart

because of import path [flutter_speed_dial_material_design]

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.0
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test