Ниже приведен минимальный фрагмент кода виджета смены пароля, воспроизводящий проблему.
Я использую flutter 3.3.10 на Windows 10 и реальном (не эмулируемом) устройстве ZTE Blade A5 с Android 9.
Форма с TextFormField для пароля и подтверждения пароля.
TextFormField оба имеют textInputAction: TextInputAction.next и InputDecoration с кнопка «показать/скрыть».
Кнопки «показать/скрыть» имеют функцию onPressed() для изменения статуса видимости содержимого поля.
При действии ввода нажатие «Далее» на кнопке клавиатуры Android в первом TextFormField, фокус не перемещается на следующее поле, если предполагается, что функция onPressed не равна нулю;
Если я устанавливаю onPressed: null в первом или оба TextFormField, textInputAction "next" работают должным образом. Я тоже попробовал focusNode, но безуспешно.
Есть ли способ заставить его работать?
Спасибо!
void main() async {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData( primarySwatch: Colors.blue ),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
final _formKey = GlobalKey();
final TextEditingController passwordController = TextEditingController();
final TextEditingController confirmPasswordController = TextEditingController();
bool _obscurePassword = true;
bool _obscureConfirmPassword = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Test"),
),
body: Center(
child: Form(
key: _formKey,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
TextFormField(
obscureText: _obscurePassword,
controller: passwordController,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.password),
suffixIcon: MaterialButton(
padding: EdgeInsets.zero,
minWidth: 0,
child: Icon(_obscurePassword ? Icons.visibility_off : Icons.visibility),
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
),
labelText: "Password",
),
),
TextFormField(
obscureText: _obscureConfirmPassword,
controller: confirmPasswordController,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.password),
suffixIcon: MaterialButton(
padding: EdgeInsets.zero,
minWidth: 0,
child: Icon(_obscureConfirmPassword ? Icons.visibility_off : Icons.visibility),
onPressed: () => setState(() => _obscureConfirmPassword = !_obscureConfirmPassword),
),
labelText: "Password confirmation",
),
),
],
),
),
),
),
);
}
}
Подробнее здесь: https://stackoverflow.com/questions/752 ... n-pressing
Flutter TextInputAction.next не переходит к следующему полю ввода при нажатии кнопки «Далее» на клавиатуре Android ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
React Native: как выбрать следующий TextInput после нажатия кнопки «Далее» на клавиатуре?
Anonymous » » в форуме IOS - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Понимание шума на экранной клавиатуре при подключенной аппаратной клавиатуре
Anonymous » » в форуме IOS - 0 Ответы
- 95 Просмотры
-
Последнее сообщение Anonymous
-