submit method
dynamic
submit(
- BuildContext context,
- dynamic callback(),
- String previousValue,
- Function post,
- String url,
- String param,
Implementation
submit(BuildContext context, Function() callback, String previousValue,
Function post, String url, String param) async {
_pressed = true;
notifyListeners();
var response = await post(
url: url,
body: <String, dynamic>{
param.toLowerCase(): _value,
},
);
if (response != null && response.statusCode == 200) {
showSuccess("$param information updated");
callback();
} else {
value = previousValue;
try {
var data = jsonDecode(response.body);
showError("${data["error"]}.");
} catch (_) {
showError("Could not update ${param.toLowerCase()} information.");
}
}
try {
_pressed = false;
notifyListeners();
} catch (_) {}
}