When the keyboard appears, the Flutter widgets resize. How to prevent this without using
resizeToAvoidBottomInset : false,
if I make it false then I can't see the TextFormField because the keyboard been above it
so waht to do?
here is my code
return Scaffold(
// resizeToAvoidBottomInset : false,
body: Center(
child: Stack(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Image.asset('images/back_ui4.png',fit: BoxFit.fill,),
),
SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 0.7*MediaQuery.of(context).size.height,),
TextFormField()
],
),
),
],
),
),
);
return Scaffold(
body: SingleChildScrollView(
child : Center(
child: Stack(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Image.asset('images/back_ui4.png',fit: BoxFit.fill,),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 0.7*MediaQuery.of(context).size.height,),
TextFormField()
],
),
),
],
),
),
);
Related
can i solve this overflow when import big image ?
I am working on an interface project only and I want to solve this problem when importing a large image
change this :
to this :
my code :
Scaffold(
backgroundColor: Color(0xff131517),
appBar : AppBar(),
body: SafeArea(
child: Directionality(
textDirection: TextDirection.rtl,
child: Column(
children: [
SizedBox(height: 10,),
Container(child: Image.file(_image! , fit: BoxFit.contain , width: MediaQuery.of(context).size.width,)),
Spacer(),
Container(
height: 85,
color:Color(0xff1e1f23),
child: Center(
child: ListView(
scrollDirection: Axis.horizontal,
children: [],
),
),
)
],
)
),
),
You need to constrain the height of the container the image is in (or of the image itself) like so:
Scaffold(
backgroundColor: Color(0xff131517),
appBar : AppBar(),
body: SafeArea(
child: Directionality(
textDirection: TextDirection.rtl,
child: Column(
children: [
SizedBox(height: 10,),
Container(
height: MediaQuery.of(context).size.height*0.9,
child: Image.file(
_image!,
fit: BoxFit.contain,
width: MediaQuery.of(context).size.width,
)
),
Spacer(),
Container(
height: 85,
color:Color(0xff1e1f23),
child: Center(
child: ListView(
scrollDirection: Axis.horizontal,
children: [],
),
),
)
],
)
),
),
It looks fine when the keyboard is hidden but when displayed the container is on top of it and it should be behind (not related to the content of the container):
SafeArea(
child: Stack(
children: [
Column(
children: <Widget>[
Expanded(child: child!),
Container(
color: Theme.of(context).primaryColorDark,
height: 90.0,
child: NativeAdWidget(),
),
],
),
],
),
)
If you use Scaffold above your code, change it with Material widget, and the problem will gone. Just like this:
return Material(
child: SafeArea(
child: Stack(
children: [
Column(
children: <Widget>[
Expanded(child: child!),
Container(
color: Theme.of(context).primaryColorDark,
height: 90.0,
child: NativeAdWidget(),
),
],
),
],
),
),
);
here is my the wiget with form
Widget verticalList = new ListView(
shrinkWrap: true,
children: [
Container(
color:Colors.white,
width: MediaQuery.of(context).size.width,
child: Form(
key: _formKey,
child:Column(
// shrinkWrap: true,
mainAxisSize:MainAxisSize.min,
children: [
textformField(),
textformField(),
textformField(),
textformField(),
textformField(),
........
.........
],
),
),
),
],
);
here below scaffold part full code
return Scaffold(
resizeToAvoidBottomInset: true,
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.center,
stops: [0.0,1,1.2],
colors: <Color>[
Color(0xff19879a),
Color(0xff000e11),
Color(0xff000e02),
],
),
),
child: Column(
children:[
Container(
height: 160,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(flex:3,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
FittedBox(child: Text("Firm Details",style: GoogleFonts.lato(color: Color(0xfffbfbfb),fontSize: 1.8*SizeConfig.textMultiplier))),
SizedBox(height: 0.5*SizeConfig.heightMultiplier,),
Padding(
padding: const EdgeInsets.only(left:30.0),
child: Text(
"Please select the category that best describes your business model.",
textAlign: TextAlign.right,
style: GoogleFonts.lato(
color: Color(0xffb3fbfbfb),
fontSize: 1.5*SizeConfig.textMultiplier),
),
),
],
),
),
),
Expanded(
flex: 2,
child: Container(
width: 10.0*SizeConfig.widthMultiplier,
height: 10.0*SizeConfig.heightMultiplier,
child: Image.asset(
"assets/images/firmDetail.png",
width: 10.0*SizeConfig.widthMultiplier,
height: 10.0*SizeConfig.heightMultiplier,
),
),
),
],
),
),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.white,
),
borderRadius: BorderRadius.only(topLeft:Radius.circular(30),topRight: Radius.circular(30))
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(flex:1,child: horizontalList1),
Expanded(flex:5,child:verticalList,),
],
),
),)
]
)
),
);
please help i tried a lot nothing worked ,
is there any problem with my code
please help i tried a lot nothing worked ,
is there any problem with my code
keypad hides my textformfield dart flutter is there any solution, it tried a lot nothing worked
Wrap everything in a SingleChildScrollView widget and you can scroll when the keyboard is displayed.
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Your Title'),
),
body: SingleChildScrollView(
child: _buildPage(),
),
);}
If you want the keyboard to hide when the user scrolls then wrap it all with NotificationListener<ScrollUpdateNotification>.
body: NotificationListener<ScrollUpdateNotification>(
onNotification: (notification) {
// dismiss keyboard on scroll if user initiated the scroll (ie dragDetails != null)
if (notification.dragDetails != null) {
FocusScope.of(context).unfocus();
}
return true;
},
child: SingleChildScrollView(
child: _buildPage(),
),
);
Wrap the form with this padding:
Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom
),
)
I have 3 Columns i want to make non scrollable screen using those columns
first 2 columns have only one one images last column have a row in which there are four icons
i want to put last column which have a row icons at the bottom of the screen for every size of screen i want same
now how its look like
body: Center(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [barColor, Colors.white])),
child: ListView(
physics: const NeverScrollableScrollPhysics(),
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/istv.png',
fit: BoxFit.cover,
),
],
),
InkWell(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/images/live.png',
fit: BoxFit.cover,
),
],
),
onTap: (){
_launchInApp(_launchUrl);
},
),
Column(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Expanded(
child: InkWell(
child :Container(
child: Image.asset(''
'assets/images/fb.png',
height: 200,
fit: BoxFit.cover,
) ,
),
onTap: (){
openfb();
},
),
),
Expanded(
child: InkWell(
child :Container(
child: Image.asset(''
'assets/images/insta.png',
height: 200,
fit: BoxFit.cover,
) ,
),
onTap: (){
openinsta();
},
),
),
Expanded(
child: InkWell(
child :Container(
child: Image.asset(''
'assets/images/yt.png',
height: 200,
fit: BoxFit.cover,
) ,
),
onTap: (){
openyt();
},
),
),
Expanded(
child: InkWell(
child :Container(
child: Image.asset(''
'assets/images/share.png',
height: 200,
fit: BoxFit.cover,
) ,
),
onTap: () {Share.share('check out my website https://example.com');}
),
)
],
),
),
],
),
],
),
)
)
If I understood your question, which was not easy, I believe this is what you want to do:
class UI62962286 extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
child: Icon(Icons.accessibility),
height: 10,
),
Container(
child: Icon(Icons.account_balance),
height: 10,
),
],
)
),
Container(
padding: EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(Icons.account_balance_wallet),
Icon(Icons.adb),
Icon(Icons.account_box),
Icon(Icons.ac_unit),
],
),
),
],
);
}
}
It looks like this:
Try this in the Widget:
body: Center(
child: Column(
children: <Widget>[
Text(
'Start Row',
),
Expanded(child:
Center(child:Text('Middle Row')),
),
Text('End Row'),
],
),
),
Where you see the text you want to insert a Row. Expand takes all the space in the middle no matter how big your screen. You can cascade that design idea.
This is my code and here I just want to know how to add text below the images.
Just let me know, please?
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: Image.asset('assets/cat.jpg',
),
),
Expanded(
child: Image.asset('assets/cat.jpg'),
),
Expanded(
child: Image.asset('assets/cat.jpg'),
),
],
),
Card(
elevation: 5,
child: Column(
children: <Widget>[
Expanded(
child: Image.asset('assets/img.jpg'),
),
Text('My Image'),
],
),
),
You can put this code row or as you want. You can also put some padding to arrange the text image. If you want constant height and weight put this into a Container Widget and specify the height and weight. Thanks.
child: Column(children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: Column(
children: <Widget>[
Image.asset(
'assets/cat.jpg',
),
Text('cat')
],
),
),
Expanded(
child: Column(
children: <Widget>[
Image.asset('assets/cat.jpg'),
Text('cat')
],
),
),
Expanded(
child: Column(
children: <Widget>[
Image.asset('assets/cat.jpg'),
Text('cat')
],
),
),
],
)
]);
},
)
If you want to add a line of text below the images at once
Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: Image.asset('assets/cat.jpg',
),
),
Expanded(
child: Image.asset('assets/cat.jpg'),
),
Expanded(
child: Image.asset('assets/cat.jpg'),
),
],
),
Text("Your text here"),
]), // column widget ends here
If you want to add text below each image then
change your Expanded widget with this.
Expanded(
child: Column(
children : <Widget>[
Image.asset('assets/cat.jpg'),
Text("your text here")
]
)
),
else create a function to return a widget as it seems you have plenty of widgets of that kind
Widget getWidget(imagePath, text){
return Expanded(
child: Column(
children : <Widget>[
Image.asset(imagePath),
Text(text)
]
)
)
}
and then use this
Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
getWidget('assets/cat.jpg','your text here'),
getWidget('assets/cat.jpg','your text here'),
getWidget('assets/cat.jpg','your text here'),
],
),
]),
You just need to wrap the image in a Column/Stack
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: Column(children: <Widget>[
Image.asset('assets/cat.jpg'),
Text('Some text')
],)
),
Expanded(
child: Column(children: <Widget>[
Image.asset('assets/cat.jpg'),
Text('Some text')
],)
),
Expanded(
child: Column(children: <Widget>[
Image.asset('assets/cat.jpg'),
Text('Some text')
],)
),
],
),