fix: show image question with delayed
#55
Merged
amirreza.chegini
merged 1 commits from fix/videos into develop 1 week ago
3 changed files with 74 additions and 10 deletions
-
59lib/core/widgets/animations/fade_anim_delayed.dart
-
1lib/features/question/presentation/bloc/question_bloc.dart
-
24lib/features/question/presentation/ui/screens/question_screen.dart
@ -0,0 +1,59 @@ |
|||
import 'package:flutter/material.dart'; |
|||
|
|||
class FadeAnimDelayed extends StatefulWidget { |
|||
const FadeAnimDelayed({ |
|||
super.key, |
|||
required this.child, |
|||
required this.duration, |
|||
}); |
|||
|
|||
final Widget child; |
|||
final Duration duration; |
|||
|
|||
@override |
|||
State<FadeAnimDelayed> createState() => _FadeAnimDelayedState(); |
|||
} |
|||
|
|||
class _FadeAnimDelayedState extends State<FadeAnimDelayed> |
|||
with SingleTickerProviderStateMixin { |
|||
late AnimationController _controller; |
|||
late Animation<double> _animation; |
|||
|
|||
@override |
|||
void initState() { |
|||
super.initState(); |
|||
_controller = AnimationController( |
|||
vsync: this, |
|||
duration: Duration(milliseconds: 500), |
|||
reverseDuration: Duration(seconds: 500), |
|||
); |
|||
_animation = Tween<double>( |
|||
begin: 0, |
|||
end: 1, |
|||
).animate(CurvedAnimation(parent: _controller, curve: Curves.linear)); |
|||
|
|||
startAnim(); |
|||
} |
|||
|
|||
Future<void> startAnim() async { |
|||
await Future.delayed(widget.duration, () { |
|||
_controller.forward(); |
|||
}); |
|||
} |
|||
|
|||
@override |
|||
void dispose() { |
|||
_controller.dispose(); |
|||
super.dispose(); |
|||
} |
|||
|
|||
@override |
|||
Widget build(BuildContext context) { |
|||
return AnimatedBuilder( |
|||
animation: _controller, |
|||
child: widget.child, |
|||
builder: (context, child) => |
|||
FadeTransition(opacity: _animation, child: child), |
|||
); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue