mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-25 04:49:36 +00:00
58 lines
1.2 KiB
Dart
58 lines
1.2 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class FadeStack extends StatefulWidget {
|
||
|
final int index;
|
||
|
final List<Widget> children;
|
||
|
|
||
|
const FadeStack({
|
||
|
super.key,
|
||
|
required this.index,
|
||
|
required this.children,
|
||
|
});
|
||
|
|
||
|
@override
|
||
|
FadeStackState createState() => FadeStackState();
|
||
|
}
|
||
|
|
||
|
class FadeStackState extends State<FadeStack>
|
||
|
with SingleTickerProviderStateMixin {
|
||
|
late final AnimationController animationController;
|
||
|
|
||
|
@override
|
||
|
void didUpdateWidget(FadeStack oldWidget) {
|
||
|
if (widget.index != oldWidget.index) {
|
||
|
animationController.forward(from: 0.0);
|
||
|
}
|
||
|
super.didUpdateWidget(oldWidget);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
animationController = AnimationController(
|
||
|
vsync: this,
|
||
|
duration: const Duration(
|
||
|
milliseconds: 250,
|
||
|
),
|
||
|
);
|
||
|
animationController.forward();
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void dispose() {
|
||
|
animationController.dispose();
|
||
|
super.dispose();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return FadeTransition(
|
||
|
opacity: animationController,
|
||
|
child: IndexedStack(
|
||
|
index: widget.index,
|
||
|
children: widget.children,
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|