apiLoad method

dynamic apiLoad(
  1. BuildContext context,
  2. dynamic updateUI(),
  3. int? testRecordId,
  4. dynamic snackHere(
    1. dynamic
    ),
)

apiLoad loads a record from the https://flutster.com API.

Implementation

apiLoad(
  BuildContext context,
  Function() updateUI,
  int? testRecordId,
  Function(dynamic) snackHere,
) async {
  if (testRecordId == null) {
    snack("Test record id is null, cannot load.", context);
    return;
  }
  apiLoadOngoing = true;
  updateUI();
  testNameFieldController.text = "";
  widget.flutsterTestRecord.clear();
  String? res;
  try {
    res = await widget.flutsterTestRecord.fromApi(
      testRecordId,
      flutsterTestRecorderState: this,
    );
  } catch (e, st) {
    res = "Failed to load test record from API";
    debugPrint("$e $st");
  }
  apiLoadOngoing = false;
  snackHere(
    res,
  );
  updateUI();
}