draggable_floating_button 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

draggable_floating_button #

We all like the Floating Action Button Widget, but how can it be better?

Well, we made a Draggable Floating Action Button!

You can use it to make the user interact in crazy and unexpected ways with your application.

How Can I Get This Widget? #

  1. Add draggable_floating_button to your pubspec.yaml file
  2. When the notification bar pops up in Android Studio prompting you to get Packages, do so

Get Packages

  1. Add an import statement in your Dart code like so, import 'package:draggable_floating_button/draggable_floating_button.dart';
  2. You are ready to create draggable floating actions buttons

Usage #

      DraggableFloatingActionButton(
          offset: new Offset(200, 200),
          backgroundColor: Theme.of(context).accentColor,
          child: new Icon(
               Icons.your_icon,
               color: lightDfabColor,
              ),
          onPressed: () => foo(),
          appContext: context,
          appBar: appBar,
          data: 'your_data',
      );

The Draggable Floating Action Button (or DFAB), can be created just like the Floating Action Button, but it has a few features in addition:

  • You need to pass in an Offset object, to letting the button know where to position itself

  • You need to pass in the context and appBar of your application in order for the button to calculate correctly which where it has been dragged to across the application.

  • The data field works in a similar fashion it works in a Draggable widget

[0.1.1] - 20/4/2019.

Added support for mini draggable floating button

[0.1.0] - 1/4/2019.

Increased version to 0.1.0 since this project is no longer experimental

[0.0.5] - 31/3/2019.

Shorter description and adding Tomer Ben Rachel as an author

[0.0.3] - 30/3/2019.

Example file was added. Package description has more data

example/example.dart

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Draggable FAB Demo',
      home: new MyHomePage(title: 'Flutter Draggable FAB Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  AppBar appBar;
  bool accepted = false;

  @override
  Widget build(BuildContext context) {
    appBar = getAppBar();

    return Scaffold(
        appBar: appBar,
        body: Stack(children: <Widget>[
          DraggableFloatingActionButton(
              data: 'dfab_demo',
              offset: new Offset(100, 100),
              backgroundColor: Theme.of(context).accentColor,
              child: new Icon(
                Icons.wb_incandescent,
                color: Colors.yellow,
              ),
              onPressed: () => print('pressed'),
              appContext: context,
              appBar: appBar)
        ]));
  }

  getAppBar() {
    return AppBar(
      title: Text(widget.title),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  draggable_floating_button: ^0.1.1

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:draggable_floating_button/draggable_floating_button.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
77
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 Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test