build method

  1. @override
Widget build(
  1. BuildContext context,
  2. PresetBuilder model
)
override

Builds the UI according to the state in model.

Implementation

@override
Widget build(BuildContext context, PresetBuilder model) => AlertDialog(
  title: const Text("Save a preset"),
  content: Column(
    mainAxisSize: MainAxisSize.min,
    children: [
      SizedBox(
        height: 50,
        width: double.infinity,
        child: TextField(
          autofocus: true,
          controller: model.nameController,
          decoration: const InputDecoration(hintText: "Preset Name"),
          onSubmitted: (_) => save(context, model),
        ),
      ),
    ],
  ),
  actions: [
    TextButton(
      child: const Text("Cancel"),
      onPressed: () => Navigator.of(context).pop(),
    ),
    ElevatedButton(
      onPressed: !model.isValid ? null : () => save(context, model),
      child: const Text("Save"),
    ),
  ],
);