💄 Auto dismiss error
This commit is contained in:
parent
90dc3f43a7
commit
3d23152802
@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -6,12 +7,16 @@ import 'package:get/get.dart';
|
||||
class ErrorNotifier extends GetxController {
|
||||
Rx<MaterialBanner?> showing = Rx(null);
|
||||
|
||||
Timer? _autoDismissTimer;
|
||||
|
||||
void logError(String msg, {StackTrace? trace}) {
|
||||
log('$msg${trace != null ? '\nTrace:\n$trace' : ''}');
|
||||
showError(msg);
|
||||
}
|
||||
|
||||
void showError(String msg) {
|
||||
_autoDismissTimer?.cancel();
|
||||
|
||||
showing.value = MaterialBanner(
|
||||
dividerColor: Colors.transparent,
|
||||
leading: const Icon(Icons.error),
|
||||
@ -34,5 +39,9 @@ class ErrorNotifier extends GetxController {
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
_autoDismissTimer = Timer(const Duration(seconds: 3), () {
|
||||
showing.value = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user