|  |  |  | @ -1,11 +1,41 @@ | 
		
	
		
			
				|  |  |  |  | import 'dart:io'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import 'package:flutter/material.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:just_audio/just_audio.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:lottie/lottie.dart'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class SuccessDialog extends StatelessWidget { | 
		
	
		
			
				|  |  |  |  | class SuccessDialog extends StatefulWidget { | 
		
	
		
			
				|  |  |  |  |   bool isFromDashboard; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   SuccessDialog(this.isFromDashboard); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   State<SuccessDialog> createState() => _SuccessDialogState(); | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class _SuccessDialogState extends State<SuccessDialog> with TickerProviderStateMixin { | 
		
	
		
			
				|  |  |  |  |   late AnimationController _controller; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   void initState() { | 
		
	
		
			
				|  |  |  |  |     _controller = AnimationController(vsync: this); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     super.initState(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> playSuccessSound() async { | 
		
	
		
			
				|  |  |  |  |     AudioPlayer player = AudioPlayer(); | 
		
	
		
			
				|  |  |  |  |     String audioAsset = ""; | 
		
	
		
			
				|  |  |  |  |     if (Platform.isAndroid) { | 
		
	
		
			
				|  |  |  |  |       audioAsset = "assets/audio/success_tone_android.mp3"; | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |       audioAsset = "assets/audio/success_tone_ios.caf"; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     await player.setAsset(audioAsset); | 
		
	
		
			
				|  |  |  |  |     await player.load(); | 
		
	
		
			
				|  |  |  |  |     player.play(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   Widget build(BuildContext context) { | 
		
	
		
			
				|  |  |  |  |     double size = MediaQuery.of(context).size.width / 1.8; | 
		
	
	
		
			
				
					|  |  |  | @ -18,13 +48,22 @@ class SuccessDialog extends StatelessWidget { | 
		
	
		
			
				|  |  |  |  |           width: size, | 
		
	
		
			
				|  |  |  |  |           height: size, | 
		
	
		
			
				|  |  |  |  |           child: Card( | 
		
	
		
			
				|  |  |  |  |             child: Lottie.asset('assets/lottie/lt_success.json', repeat: false, reverse: false, onLoaded: (v) { | 
		
	
		
			
				|  |  |  |  |               print("calling_lottie " + v.seconds.toString()); | 
		
	
		
			
				|  |  |  |  |               Future.delayed(Duration(seconds: 2)).then((value) { | 
		
	
		
			
				|  |  |  |  |                 Navigator.pop(context); | 
		
	
		
			
				|  |  |  |  |                 if (isFromDashboard) Navigator.pop(context); | 
		
	
		
			
				|  |  |  |  |               }); | 
		
	
		
			
				|  |  |  |  |             }), | 
		
	
		
			
				|  |  |  |  |             child: Lottie.asset( | 
		
	
		
			
				|  |  |  |  |               'assets/lottie/lt_success.json', | 
		
	
		
			
				|  |  |  |  |               repeat: false, | 
		
	
		
			
				|  |  |  |  |               reverse: false, | 
		
	
		
			
				|  |  |  |  |               controller: _controller, | 
		
	
		
			
				|  |  |  |  |               onLoaded: (LottieComposition v) async { | 
		
	
		
			
				|  |  |  |  |                 print("calling_lottie " + v.seconds.toString()); | 
		
	
		
			
				|  |  |  |  |                 await playSuccessSound(); | 
		
	
		
			
				|  |  |  |  |                 _controller | 
		
	
		
			
				|  |  |  |  |                   ..duration = v.duration | 
		
	
		
			
				|  |  |  |  |                   ..forward().whenComplete(() async { | 
		
	
		
			
				|  |  |  |  |                     Navigator.pop(context); | 
		
	
		
			
				|  |  |  |  |                     if (widget.isFromDashboard) Navigator.pop(context); | 
		
	
		
			
				|  |  |  |  |                   }); | 
		
	
		
			
				|  |  |  |  |               }, | 
		
	
		
			
				|  |  |  |  |             ), | 
		
	
		
			
				|  |  |  |  |           ), | 
		
	
		
			
				|  |  |  |  |         ), | 
		
	
		
			
				|  |  |  |  |       ], | 
		
	
	
		
			
				
					|  |  |  | 
 |