43 lines
1.0 KiB
Dart
43 lines
1.0 KiB
Dart
|
import 'package:energy_bilance/models/MyInputModel.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:provider/provider.dart';
|
||
|
|
||
|
class MyCustomForm extends StatefulWidget {
|
||
|
const MyCustomForm({super.key});
|
||
|
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return MyCustomFormState();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class MyCustomFormState extends State<MyCustomForm> {
|
||
|
|
||
|
final _formKey = GlobalKey<FormState>();
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Form(
|
||
|
key: _formKey,
|
||
|
child: Column(
|
||
|
children: <Widget>[
|
||
|
TextFormField(
|
||
|
decoration: const InputDecoration(
|
||
|
labelText: 'Gib was ein',
|
||
|
hintText: 'keine Zahlen bidde'
|
||
|
),
|
||
|
validator: (String? value) {
|
||
|
return (value != null && value.contains('@')) ? 'Do not use the @ char.' : null;
|
||
|
},
|
||
|
onChanged: (value) {
|
||
|
Provider.of<MyInputModel>(context, listen: false).changeText(value);
|
||
|
}
|
||
|
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|