fly_animation 0.0.2 copy "fly_animation: ^0.0.2" to clipboard
fly_animation: ^0.0.2 copied to clipboard

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

example/lib/main.dart

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
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
9
likes
130
points
20
downloads

Publisher

verified publisherdroidbiz.in

Weekly Downloads

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

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on fly_animation