Skip to main content

animation_pool 0.0.1 copy "animation_pool: ^0.0.1" to clipboard
animation_pool: ^0.0.1 copied to clipboard

animation_pool is a package that allows you to implement a pool of reused animations, without recreating them

example/lib/main.dart

import 'package:animation_pool/animation_pool.dart';
import './new_screen.dart';

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      showPerformanceOverlay: true,
      title: 'Animation Pool',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Animation Pool Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        floatingActionButton: FloatingActionButton(onPressed: () {
          AnimationPoolScope.disposeControllers(context);
          Navigator.pushReplacement(
              context, MaterialPageRoute(builder: (context) => const NewScreen()));
        }),
        body: AnimationPoolScope(
          tickerProvider: this,
          maxAnimCount: 14,
          duration: const Duration(milliseconds: 350),
          child: ListView.builder(
            itemBuilder: (context, index) => ScaleTransition(
                scale: AnimationPoolScope.getFromPool(context, index),
                child: Padding(
                  padding: const EdgeInsets.all(10),
                  child: Container(
                    width: MediaQuery.of(context).size.width * .7,
                    height: 50,
                    color: Colors.blueAccent,
                  ),
                )),
          ),
        ));
  }

  @override
  void dispose() {
    //AnimationPoolScope.disposeControllers(context);
    super.dispose();
  }
}
2
likes
150
points
41
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

animation_pool is a package that allows you to implement a pool of reused animations, without recreating them

Repository (GitHub)

License

MIT (license)

Dependencies

flutter

More

Packages that depend on animation_pool