multicontroller 0.1.1 multicontroller: ^0.1.1 copied to clipboard
MultiController is a widget that helps to create and dispose of multiple Controller (extending AnimationController), as well as chaining controllers for more advanced animations.
example/multicontroller_example.dart
import 'package:flutter/material.dart';
import 'package:multicontroller/multicontroller.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(
MaterialApp(
home: ExampleAnimation(),
),
);
}
class ExampleAnimation extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: MultiController(
builder: (context, createController, child) {
// Initializing controllers with the provided createController function.
Controller finishFirst = createController(
ControllerData(duration: Duration(seconds: 1)),
);
Controller finishLast = createController(
ControllerData(duration: Duration(seconds: 2), lowerBound: 0.5),
);
// Call chain function to start a controller after another finish.
finishFirst.chain(finishLast);
finishFirst.forward();
return Column(
children: <Widget>[
AnimatedBuilder(
animation: finishFirst,
builder: (context, child) => Text(
"This should finish ${finishFirst.value}",
),
),
AnimatedBuilder(
animation: finishLast,
builder: (context, child) => Text(
"Before this ${finishLast.value}",
),
),
],
);
},
),
),
),
);
}
}