5d333522a5
and rewrote the component's network requests. showSimpleSnackbar, allows displaying a simple snackbar, with text and one action button, that can be clicked. doNetworkRequest is supposed to be a wrapper for the already existing post* functions. It aims to make network requests and error handling easier, by containing all the try&catch blocks and being able to show snackbars.
21 lines
526 B
Dart
21 lines
526 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
void showSimpleSnackbar(ScaffoldMessengerState scaffMgr,
|
|
{required String text, required String action, Function? onTap}) {
|
|
final snackBar = SnackBar(
|
|
behavior: SnackBarBehavior.floating,
|
|
content: Text(text),
|
|
action: SnackBarAction(
|
|
label: action,
|
|
onPressed: () {
|
|
scaffMgr.hideCurrentSnackBar();
|
|
if (onTap != null) {
|
|
onTap();
|
|
}
|
|
},
|
|
),
|
|
);
|
|
|
|
scaffMgr.hideCurrentSnackBar();
|
|
scaffMgr.showSnackBar(snackBar);
|
|
}
|