bouncing_widget 1.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

bouncing_widget #

A widget that enables you to add a bouncing animation on a widget.

Example #

How does it work ? #

You just have to encapsulate the widget of your choice with a BouncingWidget.

You may also use a scaleFactor to customize the scaling effect as in the gif example. Or even customize the animation's duration with the duration parameter (200 milliseconds by default).

BouncingWidget(
  duration: Duration(milliseconds: 100),
  scaleFactor: 1.5,
  onPressed: () {
    print("onPressed");
  },
  child: Text(
    "Hello !",
    style: TextStyle(
      color: Colors.white,
      fontWeight: FontWeight.bold,
      fontSize: 35,
    ),
  ),
),

[1.0.0] - First version #

  • Create the BouncingWidget

[1.1.0] - Add scale factor customization #

  • Scale factor is now customizable with a double

[1.2.0] - Fix disposing and add some changes #

  • Fix the call on controller dispose method
  • Add the ability to customize the animation duration
  • Make the animation appears even on simple click

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  double _scaleFactor = 1.0;

  _onPressed(BuildContext context) {
    print("CLICK");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xFF8185E2),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            BouncingWidget(
              scaleFactor: _scaleFactor,
              onPressed: () => _onPressed(context),
              child: Container(
                height: 60,
                width: 270,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(100.0),
                  color: Colors.white,
                ),
                child: Center(
                  child: Text(
                    'Subscribe',
                    style: TextStyle(
                      fontSize: 20.0,
                      fontWeight: FontWeight.bold,
                      color: Color(0xFF8185E2),
                    ),
                  ),
                ),
              ),
            ),
            SizedBox(
              height: 40,
            ),
            BouncingWidget(
              scaleFactor: _scaleFactor,
              onPressed: () => _onPressed(context),
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.white,
                  shape: BoxShape.circle,
                ),
                child: Padding(
                  padding: const EdgeInsets.all(12.0),
                  child: Icon(Icons.add),
                ),
              ),
            ),
            SizedBox(
              height: 40,
            ),
            BouncingWidget(
              scaleFactor: _scaleFactor,
              onPressed: () => _onPressed(context),
              child: Text(
                "Hello !",
                style: TextStyle(
                  color: Colors.white,
                  fontWeight: FontWeight.bold,
                  fontSize: 35,
                ),
              ),
            ),
            Container(
              width: MediaQuery.of(context).size.width * .5,
              child: Slider(
                activeColor: Colors.amber,
                inactiveColor: Colors.amberAccent,
                min: -5,
                max: 5,
                value: _scaleFactor,
                onChanged: (double newValue) {
                  setState(() {
                    _scaleFactor = newValue;
                  });
                },
              ),
            ),
            Center(
              child: Text(
                "Scale factor = ${num.parse(_scaleFactor.toStringAsFixed(2))}",
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 20,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  bouncing_widget: ^1.2.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:bouncing_widget/bouncing_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
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]
86
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/bouncing_widget.dart.

Run flutter format to format lib/bouncing_widget.dart.

Dependencies

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