show static method

Future<Map<String, dynamic>?> show(
  1. BuildContext context,
  2. String code
)

Implementation

static Future<Map<String, dynamic>?> show(BuildContext context, String code) {
  final action =
      session.profile.actions.firstWhere((element) => element.name == code);
  var appState = Provider.of<BizDocAppState>(context, listen: false);
  var args = <String, dynamic>{};
  return showDialog<Map<String, dynamic>>(
    context: context,
    builder: (context) {
      return AlertDialog(
        title: Text(action.title),
        content: action.template != null
            ? appState.resolve(action.template!, context)
            : Fields(
                fields: action.arguments,
                onChanged: (values) => args.addAll(values)),
        actions: [
          TextButton(
            child: Text(AppLocalizations.of(context)!.cancel),
            onPressed: () => Navigator.pop(context),
          ),
          TextButton(
            child: Text(AppLocalizations.of(context)!.ok),
            onPressed: () => Navigator.pop(context, args),
          )
        ],
      );
    },
  );
}