Add Beneficiary Validation API integration
This commit is contained in:
@@ -1,18 +1,84 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lottie/lottie.dart';
|
||||||
|
import 'package:confetti/confetti.dart';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
class BeneficiaryResultPage extends StatelessWidget {
|
class BeneficiaryResultPage extends StatefulWidget {
|
||||||
final bool isSuccess;
|
final bool isSuccess;
|
||||||
|
|
||||||
const BeneficiaryResultPage({super.key, required this.isSuccess});
|
const BeneficiaryResultPage({super.key, required this.isSuccess});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BeneficiaryResultPage> createState() => _BeneficiaryResultPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
|
||||||
|
late ConfettiController _confettiController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_confettiController =
|
||||||
|
ConfettiController(duration: const Duration(seconds: 3));
|
||||||
|
if (widget.isSuccess) {
|
||||||
|
_confettiController.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_confettiController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final successAnimation = 'assets/animations/done.json';
|
||||||
|
final errorAnimation = 'assets/animations/error.json';
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
backgroundColor: widget.isSuccess ? Colors.green[50] : Colors.red[50],
|
||||||
child: Text(
|
body: Stack(
|
||||||
isSuccess ? 'Beneficiary Added Successfully!' : 'Beneficiary Addition Failed!',
|
alignment: Alignment.center,
|
||||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Lottie.asset(
|
||||||
|
widget.isSuccess ? successAnimation : errorAnimation,
|
||||||
|
width: 150,
|
||||||
|
height: 150,
|
||||||
|
repeat: false,
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
widget.isSuccess
|
||||||
|
? 'Beneficiary Added Successfully!'
|
||||||
|
: 'Beneficiary Addition Failed!',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: widget.isSuccess ? Colors.green : Colors.red,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (widget.isSuccess)
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: ConfettiWidget(
|
||||||
|
confettiController: _confettiController,
|
||||||
|
blastDirection: pi / 2,
|
||||||
|
maxBlastForce: 10,
|
||||||
|
minBlastForce: 5,
|
||||||
|
emissionFrequency: 0.05,
|
||||||
|
numberOfParticles: 20,
|
||||||
|
gravity: 0.2,
|
||||||
|
shouldLoop: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user