2024-05-19 16:08:20 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
extension SolianExtenions on BuildContext {
|
|
|
|
void showSnackbar(String content) {
|
|
|
|
ScaffoldMessenger.of(this).showSnackBar(SnackBar(
|
|
|
|
content: Text(content),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> showErrorDialog(dynamic exception) {
|
|
|
|
String formatMessage(dynamic exception) {
|
|
|
|
final message = exception.toString();
|
|
|
|
if (message.trim().isEmpty) return '';
|
|
|
|
return message
|
|
|
|
.split(' ')
|
2024-06-01 12:18:25 +00:00
|
|
|
.map((element) =>
|
|
|
|
'${element[0].toUpperCase()}${element.substring(1).toLowerCase()}')
|
2024-05-19 16:08:20 +00:00
|
|
|
.join(' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
return showDialog<void>(
|
2024-06-01 12:18:25 +00:00
|
|
|
useRootNavigator: true,
|
2024-05-19 16:08:20 +00:00
|
|
|
context: this,
|
|
|
|
builder: (ctx) => AlertDialog(
|
|
|
|
title: Text('errorHappened'.tr),
|
|
|
|
content: Text(formatMessage(exception)),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => Navigator.pop(ctx),
|
|
|
|
child: Text('okay'.tr),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|