build method
- @override
- BuildContext context,
- CameraDetailsBuilder model
override
Builds the UI according to the state in model
.
Implementation
@override
Widget build(BuildContext context, CameraDetailsBuilder model) => AlertDialog(
title: const Text("Modify camera"),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text("Cancel"),
),
ElevatedButton(
onPressed: !model.isValid ? null : () async {
final result = await model.saveSettings(data.id);
if (result && context.mounted) Navigator.of(context).pop();
},
child: const Text("Save"),
),
],
content: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: DropdownEditor<CameraStatus>(
name: "Status",
humanName: (value) => value.humanName,
value: model.status,
onChanged: model.updateStatus,
items: CameraDetailsBuilder.okStatuses,
),
),
NumberEditor(
name: "Resolution height",
model: model.resolutionHeight,
titleFlex: 2,
),
NumberEditor(
name: "Resolution width",
model: model.resolutionWidth,
titleFlex: 2,
),
NumberEditor(
name: "Quality (0-100)",
model: model.quality,
titleFlex: 2,
),
NumberEditor(
name: "Frames per second",
model: model.fps,
titleFlex: 2,
),
const SizedBox(height: 24),
if (model.isLoading) const Text("Loading..."),
if (model.error != null) Text(model.error!, style: const TextStyle(color: Colors.red)),
],
),
),
);