extrasData static method

dynamic extrasData({
  1. required BuildContext context,
  2. required Map? data,
  3. required dynamic onSuccess(
    1. Map data
    ),
  4. Function? onFailure,
  5. List<String> keys = const <String>[],
})

check data from page (if onFailure null then page finish)

Implementation

static extrasData(
    {required BuildContext context,
    required Map? data,
    required Function(Map data) onSuccess,
    Function? onFailure,
    List<String> keys = const <String>[]}) {
  if (data != null) {
    bool isAllKeyContains = true;
    for (String key in keys) {
      if (!data.containsKey(key)) {
        isAllKeyContains = false;
        break;
      }
    }
    if (isAllKeyContains) {
      onSuccess(data);
    } else {
      log("onFailure");
      if (onFailure != null) {
        onFailure();
      } else {
        NavigatorName.finish(context);
      }
    }
  } else {
    log("onFailure");
    if (onFailure != null) {
      onFailure();
    } else {
      NavigatorName.finish(context);
    }
  }
}