I'm writing a Flutter app and I have a problem with the TextField widget.
On tap in the TextField a strange toolbar appears instead of the keyboard.
In addition something is injected into the widget tree and the layout is destroyed.
This happens on the emulator with API 36 or 35 (emulator with API less than 35 works as expected).
I didn't test on a real device.
How can I disable this toolbar, I need the keyboard?
Here is the code:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
onBackPressed: _onBackPressed,
centerTitle: true,
title: Text(AppLocalizations.of(context)!.recover_password),
),
body: SafeArea(
child: SingleChildScrollView(
child: _buildBody(),
),
),
);
}
Widget _buildBody() {
final bodyHeight = MediaQuery.of(context).size.height -
(MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom + kToolbarHeight);
return Container(
height: bodyHeight,
child: Column(
children: [
const SizedBox(height: 16.0,),
_buildEmail(),
const Spacer(),
_buildRecoverButton(),
],
),
);
}
Widget _buildEmail() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: TextField(controller: _controller,
autocorrect: false,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
labelText: AppLocalizations.of(context)!.email,
floatingLabelAlignment: FloatingLabelAlignment.start,
floatingLabelBehavior: FloatingLabelBehavior.auto,
contentPadding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
filled: true,
fillColor: Colors.black12,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(8.0),
),
),
onChanged: (value) {
final isValid = EmailValidator.validate(value.trim());
setState(() {
_isButtonEnabled = isValid;
});
},
),
);
}
Widget _buildRecoverButton() {
return Container(width: double.infinity, height: 48,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
...
),
);
}
And that's what I see:
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744279665a4566507.html
评论列表(0条)