mirror of
https://github.com/friebetill/TubeCards.git
synced 2025-08-15 02:26:03 +08:00
52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../i18n/i18n.dart';
|
|
import '../../../widgets/stadium_text_field.dart';
|
|
|
|
class EmailField extends StatefulWidget {
|
|
const EmailField(
|
|
this.onChanged,
|
|
this.errorText,
|
|
this._fieldFocus,
|
|
this.onSubmitted, {
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
final String? errorText;
|
|
final ValueChanged<String> onChanged;
|
|
final FocusNode _fieldFocus;
|
|
final VoidCallback onSubmitted;
|
|
|
|
@override
|
|
EmailFieldState createState() => EmailFieldState();
|
|
}
|
|
|
|
class EmailFieldState extends State<EmailField> {
|
|
final _textEditingController = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return StadiumTextField(
|
|
key: const ValueKey('email-field'),
|
|
autofillHints: const [AutofillHints.email],
|
|
controller: _textEditingController,
|
|
placeholder: S.of(context).email,
|
|
keyboardType: TextInputType.emailAddress,
|
|
textInputAction: TextInputAction.done,
|
|
focusNode: widget._fieldFocus,
|
|
onFieldSubmitted: (term) {
|
|
widget._fieldFocus.unfocus();
|
|
widget.onSubmitted();
|
|
},
|
|
errorText: widget.errorText,
|
|
onChanged: widget.onChanged,
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_textEditingController.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|