mirror of
https://github.com/rainloreley/shlink-manager.git
synced 2024-11-13 23:05:14 +01:00
22 lines
622 B
Dart
22 lines
622 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shlink_app/API/server_manager.dart';
|
|
|
|
SnackBar buildApiErrorSnackbar(Failure r, BuildContext context) {
|
|
var text = "";
|
|
|
|
if (r is RequestFailure) {
|
|
text = r.description;
|
|
} else {
|
|
text = (r as ApiFailure).detail;
|
|
if ((r).invalidElements != null) {
|
|
text = "$text: ${(r).invalidElements}";
|
|
}
|
|
}
|
|
|
|
final snackBar = SnackBar(
|
|
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
backgroundColor: Theme.of(context).colorScheme.error,
|
|
behavior: SnackBarBehavior.floating);
|
|
|
|
return snackBar;
|
|
} |