willPop static method

dynamic willPop(
  1. dynamic context, {
  2. dynamic model,
})

Implementation

static willPop(context, {model}) {
  if (model != null) {
    if (Dynamic(model).changed(RapidFireAppRF.of(context)!.initialModel)) {
      rf.msg(
        context,
        'Save change pending, do you want to quite anyway?',
        icon: Icons.error,
        actionText: 'Quit',
        action: () => Navigator.pop(context),
      );
    } else {
      if (Navigator.canPop(context)) {
        Navigator.pop(context);
      } else {
        //SystemChannels.platform.invokeMethod('SystemNavigator.pop');
        SystemNavigator.pop();
      }
    }
  } else {
    if (Navigator.canPop(context)) {
      Navigator.pop(context);
    } else {
      //SystemChannels.platform.invokeMethod('SystemNavigator.pop');
      SystemNavigator.pop();
    }
  }
  return Future.value(true);
}