import 'package:desktopapp/widgets/components/row_input.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class EmailForm extends StatelessWidget { EmailForm({Key? key, required this.onValid, required this.prefs}) : super(key: key); final void Function(String, String) onValid; final SharedPreferences prefs; final TextEditingController _emailController = TextEditingController(); final TextEditingController _passwordController = TextEditingController(); @override Widget build(BuildContext context) { _emailController.text = prefs.getString('mail_email') ?? ''; _passwordController.text = prefs.getString('mail_password') ?? ''; return Column(children: [ RowInput(label: 'Email', controller: _emailController), RowInput( label: 'Password', controller: _passwordController, obscureText: true), TextButton( onPressed: () async { prefs.setString('mail_email', _emailController.text.trim()); prefs.setString('mail_password', _passwordController.text.trim()); onValid(_emailController.text, _passwordController.text); }, child: const Text('Se connecter')), ]); } }