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 createState() { return MyCustomFormState(); } } class MyCustomFormState extends State { final _formKey = GlobalKey(); @override Widget build(BuildContext context) { return Form( key: _formKey, child: Column( children: [ 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(context, listen: false).changeText(value); } ) ], ), ); } }