Code updated

This commit is contained in:
risnaman
2026-09-19 16:21:37 +05:30
parent 012969ae21
commit 212df37f8a
4 changed files with 352 additions and 357 deletions
+40 -32
View File
@@ -213,41 +213,49 @@ class _CreateAccountScreenState extends State<CreateAccountScreen> {
onTap: () async {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
{
try {
print('form data is $formData');
try {
print('form data is $formData');
final response =
await userService.createAccount(formData);
final response =
await userService.createAccount(formData);
account_id = response['account_id'].toString();
print(
'after create account account id is $account_id');
// ignore: use_build_context_synchronously
Navigator.pop(
_context, account_id); // Pop with account_id
// Navigator.pop(context);
} catch (e) {
// ignore: use_build_context_synchronously
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Error'),
content: Text('Account Creation Failed: $e'),
actions: [
TextButton(
child: const Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
var parsedId;
if (response is Map) {
parsedId = response['account_id'] ??
response['id'] ??
response['sysAccountId'] ??
response['accountId'] ??
response['item']?['account_id'] ??
response['item']?['id'];
} else {
parsedId = response;
}
account_id = parsedId?.toString();
print(
'after create account account id is $account_id');
if (!mounted) return;
Navigator.pop(context, account_id);
} catch (e) {
if (!mounted) return;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Error'),
content: Text('Account Creation Failed: $e'),
actions: [
TextButton(
child: const Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
},