Solian/lib/exts.dart

32 lines
768 B
Dart
Raw Normal View History

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),
));
}
2024-06-29 13:03:15 +00:00
void clearSnackbar() {
ScaffoldMessenger.of(this).clearSnackBars();
}
2024-05-19 16:08:20 +00:00
Future<void> showErrorDialog(dynamic exception) {
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),
2024-06-08 13:35:50 +00:00
content: Text(exception.toString().capitalize!),
2024-05-19 16:08:20 +00:00
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: Text('okay'.tr),
)
],
),
);
}
}