30 lines
791 B
Dart
30 lines
791 B
Dart
import 'package:flutter/cupertino.dart';
|
|
|
|
class FadeInWidget extends StatelessWidget {
|
|
final Widget child;
|
|
final Duration? delay;
|
|
final Future? future;
|
|
final Duration animationDuration;
|
|
|
|
FadeInWidget({
|
|
required this.child,
|
|
this.delay = const Duration(milliseconds: 200),
|
|
this.future,
|
|
this.animationDuration = const Duration(milliseconds: 200),
|
|
super.key,
|
|
}) : assert(future != null || delay != null);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder(
|
|
future: future ?? Future.delayed(delay!),
|
|
builder: (context, s) {
|
|
return AnimatedOpacity(
|
|
duration: animationDuration,
|
|
opacity: s.connectionState == ConnectionState.done ? 1.0 : 0.0,
|
|
child: child,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|