fly_animation 0.0.2 icon indicating copy to clipboard operation
fly_animation: ^0.0.2 copied to clipboard

Fly animation which animates single or multiple widgets from one position to another.

fly_animation #

Fly animation which animates single or multiple widgets from one position to another.

Usage #

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Fly Animation Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: FlyAnimationExample(),
    );
  }
}

final _animationEndWidgetKey = GlobalKey();
int starsCount = 6;

///Fly animation example widget
class FlyAnimationExample extends StatefulWidget {
  @override
  _FlyAnimationExampleState createState() => _FlyAnimationExampleState();
}

class _FlyAnimationExampleState extends State<FlyAnimationExample> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Fly Animation Example'),
      ),
      body: FlyAnimationWidget(
        animationEndKey: _animationEndWidgetKey,
        countOfAnimationWidgets: starsCount,
        topPosition: 300.0,
        childWidget: ChildWidget(),
        animationWidget: Image.asset(
          'assets/star.png',
          height: 24,
          width: 24,
        ),
        animationWidgetWidth: 30,
        animationWidgetHeight: 30,
        animationDurationInMillis: 700,
        hideAnimationWidgetOnComplete: true,
      ),
    );
  }


}

class ChildWidget extends StatefulWidget {
  @override
  _ChildWidgetState createState() => _ChildWidgetState();
}

class _ChildWidgetState extends State<ChildWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(16),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Container(
                key: _animationEndWidgetKey,
                child: Image.asset(
                  'assets/star.png',
                  height: 36,
                  width: 36,
                ),
              ),
              SizedBox(
                width: 8,
              ),
              Text(
                'Total stars: $starsCount',
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                  fontSize: 20
                ),
              ),
            ],
          ),
          SizedBox(height: 200),
          Visibility(
            visible: starsCount == 0 ? false : true,
            child: Padding(
              padding: const EdgeInsets.all(16),
              child: Text(
                'You won $starsCount stars',
                textAlign: TextAlign.center,
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 15
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Widget property details #

  • animationEndKey: key of the widget where animation ends
  • countOfAnimationWidgets: number of animation widgets need to be created
  • topPosition: top position of the animation widget to display on screen
  • childWidget: widgets tree to be displayed in screen
  • animationWidget: animation widget
  • animationWidgetWidth: animation widget width
  • animationWidgetHeight: animation widget height
  • animationDurationInMillis: animation duration in millis
  • hideAnimationWidgetOnComplete: pass true if you want to hide animation widget on animation complete
9
likes
100
pub points
43%
popularity

Publisher

verified publisher icondroidbiz.in

Fly animation which animates single or multiple widgets from one position to another.

Repository (missing)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on fly_animation