submit method

dynamic submit(
  1. BuildContext context,
  2. dynamic callback(),
  3. String? id,
  4. Function post,
)

Implementation

submit(BuildContext context, Function() callback, String? id,
    Function post) async {
  callback();
  _pressed = true;

  notifyListeners();
  var response = await post(
    url: 'result/report/?uuid=$id',
    body: {
      'uuid': id,
    },
  );

  if (response != null && response.statusCode == 200) {
    callback();
    showSuccess("CDC submission successful!");
  } else {
    try {
      var data = jsonDecode(response.body);
      showError("${data["error"]}.");
    } catch (_) {
      showError("Something went wrong.");
    }
  }
  try {
    _pressed = false;
    notifyListeners();
  } catch (_) {}
}