show static method
Shows the dialog; null when cancelled.
Implementation
static Future<({String name, String scope})?> show(BuildContext context) {
final l = NmAccount.l10n(context);
final name = TextEditingController();
var scope = 'read_only';
return NmFormDialog.show<({String name, String scope})>(
context,
title: l.apiKeyCreate,
submitLabel: l.apiKeyCreate,
builder: (context) => StatefulBuilder(
builder: (context, setState) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
NmTextField(
key: const ValueKey('api-key-name'),
controller: name,
label: l.apiKeyName,
autofocus: true,
validator: (v) => (v ?? '').trim().isEmpty ? NmL10n.of(context).fieldRequired : null,
),
const SizedBox(height: 12),
NmSegmentedControl<String>(
value: scope,
items: [
NmSegment(value: 'read_only', label: l.scopeReadOnly),
NmSegment(value: 'full', label: l.scopeFull),
],
onChanged: (v) => setState(() => scope = v),
),
],
),
),
onSubmit: () => name.text.trim().isEmpty ? null : (name: name.text.trim(), scope: scope),
);
}