requestPlanSelection function

Future<void> requestPlanSelection(
  1. BuildContext context,
  2. NmPlanController controller,
  3. String id
)

Request plan selection.

Implementation

Future<void> requestPlanSelection(BuildContext context, NmPlanController controller, String id) async {
  if (controller.requestSelectPlan(id)) return;
  final l10n = NmTelecom.l10n(context);
  final discard = await showDialog<bool>(
    context: context,
    builder: (_) => AlertDialog(
      title: Text(l10n.planUnsavedTitle),
      content: Text(l10n.planUnsavedBody),
      actions: [
        TextButton(onPressed: () => Navigator.pop(context, false), child: Text(l10n.planKeepEditing)),
        TextButton(onPressed: () => Navigator.pop(context, true), child: Text(l10n.planDiscardChanges)),
      ],
    ),
  );
  if (discard == true) {
    controller.discardAndContinue();
  } else {
    controller.keepEditing();
  }
}