mirror of
https://github.com/seemoo-lab/openhaystack.git
synced 2026-08-19 19:46:24 +00:00
35 lines
892 B
Dart
35 lines
892 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class AccessoryIdInput extends StatelessWidget {
|
|
ValueChanged<String?> changeListener;
|
|
|
|
/// Displays an input field with validation for an accessory ID.
|
|
AccessoryIdInput({
|
|
Key? key,
|
|
required this.changeListener,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
|
child: TextFormField(
|
|
decoration: const InputDecoration(
|
|
labelText: 'ID',
|
|
),
|
|
validator: (value) {
|
|
if (value == null) {
|
|
return 'ID must be provided.';
|
|
}
|
|
int? parsed = int.tryParse(value);
|
|
if (parsed == null) {
|
|
return 'ID must be an integer value.';
|
|
}
|
|
return null;
|
|
},
|
|
onSaved: changeListener,
|
|
),
|
|
);
|
|
}
|
|
}
|