Flutter Cupertino Text Field Sizing Error - flutter

When a user double taps the text to bring up "Cut Copy Paste", there is a sizing error with the pop-up and the text is cut off. I can't find any questions around this that can help.
See Screenshot and code below
Padding(
padding: const EdgeInsets.only(left: 12.0),
child: CupertinoTextField(
textCapitalization: TextCapitalization.words,
focusNode: titleFocus,
autofocus: true,
controller: titleController,
keyboardType: TextInputType.multiline,
maxLines: null,
cursorColor: Theme.of(context).cursorColor,
onSubmitted: (text) {
titleFocus.unfocus();
FocusScope.of(context)
.requestFocus(contentFocus);
},
textInputAction: TextInputAction.next,
style: GoogleFonts.roboto(
textStyle: TextStyle(
//color: Color(0xff3a4759),
fontSize: 20,
color: Theme.of(context).accentColor,
fontWeight: FontWeight.w700),
),
placeholder: "Sermon Title",
placeholderStyle: TextStyle(
color: Colors.grey.shade400,
fontSize: 20,
fontFamily: 'Helvetica Neue',
fontWeight: FontWeight.w500),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.withOpacity(0.0),
),
),
),
),

Try below code hope its help to you
Declare one Controller
final TextEditingController _controller = new TextEditingController();
Your Widget :
Column(
children:[
SizedBox(
height:30,
),
Padding(
padding: const EdgeInsets.all( 16.0),
child: CupertinoTextField(
textCapitalization: TextCapitalization.words,
autofocus: true,
controller: _controller,
keyboardType: TextInputType.multiline,
maxLines: null,
cursorColor: Theme.of(context).cursorColor,
textInputAction: TextInputAction.next,
placeholder: "Sermon Title",
placeholderStyle: TextStyle(
color: Colors.grey.shade400,
fontSize: 20,
fontFamily: 'Helvetica Neue',
fontWeight: FontWeight.w500),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.withOpacity(0.0),
),
),
),
),
],
),
Your result screen ->

Related

Change color of maxletters in textfiled flutter

How to change color of this? and position other place.( like center of top )
Code:
TextField(
maxLength: 25,
textAlign: TextAlign.center,
obscureText: obscuretext,
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(8.0),
border: InputBorder.none,
iconColor: Colors.grey.shade800,
hintText: hintText,
hintStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.grey.shade800,
),
filled: true,
fillColor: Colors.white54,
),
);
Try below code and use buildCounter
Padding(
padding: const EdgeInsets.all(16),
child: TextFormField(
maxLength: 25,
decoration: const InputDecoration(
border: OutlineInputBorder(),
// If you want change color only of counterText then refer below style
/*counterStyle: TextStyle(
color: Colors.green,
),*/
),
buildCounter: (BuildContext context,
{int? currentLength, int? maxLength, bool? isFocused}) =>
Container(
alignment: Alignment.topLeft,//use alignment position on your need
child: Text(
'${currentLength.toString()}/${maxLength.toString()}',
style: const TextStyle(
color: Colors.indigo,
),
),
),
),
),
Result Screen->
you can build your custom counter
TextField(
maxLength: 25,
buildCounter: (_, {currentLength, maxLength, isFocused}) => Container(
alignment: Alignment.centerLeft,
child: Text(currentLength.toString() + "/" + maxLength.toString()),
),
)

text align : center in a textfield in flutter

I want to make the text be written at the center of the container but it keeps being at the bottom.
Container(
width: 250.yswx,
padding: EdgeInsets.symmetric(horizontal: 5.yswx),
child: Center(
child: TextField(
textAlignVertical: TextAlignVertical.center,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontSize: 13.yswx
),
cursorColor: Colors.black,
decoration: InputDecoration(
border: InputBorder.none,
hintText: widget.placeHolder,
hintStyle: TextStyle(
color: Color(0xffbfbfbf),
fontSize: 13.yswx
)
),
),
),
);
the result:
Hope this helps:
TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: "Testing Centered",
),

Center TextFormField Flutter

how do i center this? You can see the Code next to the Emulator
Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: 120,
child: TextFormField(
inputFormatters: [
LengthLimitingTextInputFormatter(3),
],
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
style: const TextStyle(
fontSize: 16,
),
autovalidateMode: AutovalidateMode.disabled,
controller: controller,
cursorColor: Colors.white,
decoration: InputDecoration(
alignLabelWithHint: true,
floatingLabelAlignment: FloatingLabelAlignment.center,
labelText: lableText,
labelStyle: const TextStyle(fontSize: 16)),
),
),
),
I added code Snippet so you can see it better :)
you can do like this
SizedBox(
width: 120,
child: TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'In jahren',
),
),)
delete labelText and Use label instead.
give Text to label as child.
wrap label with Center.
TextFormField(
.
.
.
label: Center(
child: Text('In jahren'),
),//center
),//TextFormField

Flutter UI not moving up when keyboard appears

I don't understand why is this Scaffold not moving up when the keyboard is shown.
#override
Widget build(BuildContext context) {
if (widget.usuario.city.length < 3) {
controladorUbicacion.text = ciudadPropuesta + ", " + provinciaPropuesta;
}
if (widget.usuario.country.length < 3) {
controladorPais.text = paisPropuesto;
}
return SafeArea(
top: false,
bottom: true,
child: Scaffold(
appBar: AppBar(
backgroundColor: AppColors.rojoMovMap,
title: Text("miperfil".tr()),
),
body: SingleChildScrollView(
child: Column(
children: [
//username
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
onChanged: (text) {},
controller: controladorUsername,
decoration: InputDecoration(
hintText: 'tuusername'.tr().toString(),
hintStyle: TextStyle(color: Colors.black, fontSize: 14),
labelText: 'tuusername'.tr().toString(),
labelStyle:
TextStyle(fontSize: 18, color: AppColors.negroMovMap),
),
)),
//ubicacion
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
onChanged: (text) {},
controller: controladorUbicacion,
decoration: InputDecoration(
hintText: 'tuubicacion'.tr().toString(),
hintStyle: TextStyle(color: Colors.black, fontSize: 14),
labelText: 'tuubicacion'.tr().toString(),
labelStyle:
TextStyle(fontSize: 18, color: AppColors.negroMovMap),
),
)),
//pais
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
onChanged: (text) {},
controller: controladorPais,
decoration: InputDecoration(
hintText: 'tupais'.tr().toString(),
hintStyle: TextStyle(color: Colors.black, fontSize: 14),
labelText: 'tupais'.tr().toString(),
labelStyle:
TextStyle(fontSize: 18, color: AppColors.negroMovMap),
),
)),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
onChanged: (text) {},
controller: controladorNombre,
decoration: InputDecoration(
hintText: 'tunombre'.tr().toString(),
hintStyle: TextStyle(color: Colors.black, fontSize: 14),
labelText: 'tunombre'.tr().toString(),
labelStyle:
TextStyle(fontSize: 18, color: AppColors.negroMovMap),
),
)),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
onChanged: (text) {},
controller: controladorApellidos,
decoration: InputDecoration(
hintText: 'tusapellidos'.tr().toString(),
hintStyle: TextStyle(color: Colors.black, fontSize: 14),
labelText: 'tusapellidos'.tr().toString(),
labelStyle:
TextStyle(fontSize: 18, color: AppColors.negroMovMap),
),
)),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
onChanged: (text) {},
controller: controladorWeb,
decoration: InputDecoration(
hintText: 'tuweb'.tr().toString(),
hintStyle: TextStyle(color: Colors.black, fontSize: 14),
labelText: 'tuweb'.tr().toString(),
labelStyle:
TextStyle(fontSize: 18, color: AppColors.negroMovMap),
),
)),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
onChanged: (text) {},
decoration: InputDecoration(
hintText: 'PersonalInfoWeight'.tr().toString(),
hintStyle: TextStyle(color: Colors.black, fontSize: 14),
labelText: 'PersonalInfoWeight'.tr().toString(),
labelStyle:
TextStyle(fontSize: 18, color: AppColors.negroMovMap),
),
)),
],
),
),
),
);
}
}
Try to add inside Scaffold widget
Refer resizeToAvoidBottomInset
resizeToAvoidBottomInset: true,

Flutter : multi cursor of TextEditingController in an ExpansionTile widget

I Have couple of TextEditingControllers in an ExpansionTile.
When i click on one of them, I get multi cursor on all of the TextEditingController with it.
When i put a text in one the TextEditingController (or any action) : it affect all of the other Text in the same ExpansionTile widget.
widget build(){
...
...
ExpansionTile(
title: Container(
width: double.infinity,
child: Text("Parametre vitaux",
style: TextStyle(fontSize: 18),)),
trailing: Icon(Icons.arrow_drop_down, size: 32,
color: Colors.black,),
onExpansionChanged: (value) {
setState(() {
// isExpand=value;
});
},
children: [
listmesures()
]
)
}
Widget listmesures() {
return Container(child:
ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: [
TextFormField(
keyboardType: TextInputType.phone,
focusNode: f2,
controller: _poidsController,
style: GoogleFonts.lato(
fontSize: 18, fontWeight: FontWeight.bold),
decoration: InputDecoration(
contentPadding:
EdgeInsets.only(left: 20, top: 10, bottom: 10),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(90.0)),
borderSide: BorderSide.none,
),
filled: true,
fillColor: Colors.grey[350],
hintText: 'Poids Kg*',
hintStyle: GoogleFonts.lato(
color: Colors.black26,
fontSize: 18,
fontWeight: FontWeight.w800,
),
),
validator: (value) {
if (value.isEmpty) {
return 'entrez poids';
}
return null;
},
onFieldSubmitted: (String value) {
f2.unfocus();
FocusScope.of(context).requestFocus(f3);
},
textInputAction: TextInputAction.next,
),
SizedBox(
height: 10,
),
TextFormField(
keyboardType: TextInputType.phone,
focusNode: f2,
controller: _tempController,
style: GoogleFonts.lato(
fontSize: 18, fontWeight: FontWeight.bold),
decoration: InputDecoration(
contentPadding:
EdgeInsets.only(left: 20, top: 10, bottom: 10),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(90.0)),
borderSide: BorderSide.none,
),
filled: true,
fillColor: Colors.grey[350],
hintText: 'Temperature*',
hintStyle: GoogleFonts.lato(
color: Colors.black26,
fontSize: 18,
fontWeight: FontWeight.w800,
),
),
validator: (value) {
if (value.isEmpty) {
return 'entrez temperature';
}
return null;
},
onFieldSubmitted: (String value) {
f2.unfocus();
FocusScope.of(context).requestFocus(f3);
},
textInputAction: TextInputAction.next,
),
.....
],
));
}
ExpansionTile: It is a simple and useful widget. This widget lets you create a collapse or expansion view with features similar to ListTile. It is like a ListTile which will expand on tapping the title.
TextEditingController : Connect the TextEditingController to a text field.
I've solved using different focusNode.
$ flutter channel
Flutter channels:
stable
beta
master
first:
flutter channel stable
and
flutter upgrade
running in 2022
channel documentation
https://github.com/flutter/flutter/wiki/Flutter-build-release-channels