FLUTTER UI Config widget row with 2 dropdown - flutter

I have problem with UI in flutter. Anyone have experienced in widget please help me.
Firstly, here's the target from figma :
both date and time is using dropdown.
This is what it become after my code :
This is my code :
Container(
alignment: Alignment.centerLeft,
child: Text('Schedule',
style: TextStyle(
color: Color.fromRGBO(78, 125, 150, 1),
fontSize: 12,
fontWeight: FontWeight.w600
))),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 40,
width: MediaQuery.of(context).size.shortestSide * 0.5,
color: Colors.white,
child: DropdownButtonFormField(
onChanged: (value) {},
items: _dropdownDate.map((value) =>
DropdownMenuItem(
child: Text(value),
value: value,
)).toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month, size: 16),
hintText: 'Select Date',
hintStyle: TextStyle(fontSize: 12),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(16),
fillColor: Colors.white
),
),
),
Container(
height: 40,
width: MediaQuery.of(context).size.shortestSide * 0.3,
color: Colors.white,
child: DropdownButtonFormField(
onChanged: (value) {},
items: _dropdownTime.map((value) =>
DropdownMenuItem(
child: Text(value),
value: value,
)).toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.watch_later_outlined, size: 16),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(16),
fillColor: Colors.white
),
),
),
],
),
I want to make the size in the row like this :
50% dropdown Date,
20% space,
30% dropdown Time
and the problem are :
I don't know how to configure it as a percentage of row space, not with MediaQuery.of(context).size.width because I already use margin.
How to made the percentage is auto fit no matter device the user will used.
Hope to solved this here, thank you before~
Update, after using layout builder :

You should use the LayoutBuilder for that instead of MediaQuery. It's going to give you the available space inside the wrapped widget.
The code changes are below. This is the result:
child: LayoutBuilder(
builder: (context, constraints) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
// height: 40,
width: constraints.maxWidth * 0.5,
color: Colors.white,
child: DropdownButtonFormField(
onChanged: (value) {},
items: _dropdownDate
.map((value) => DropdownMenuItem(
child: Text(value),
value: value,
))
.toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month, size: 16),
hintText: 'Select Date',
hintStyle: TextStyle(fontSize: 12),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(16),
fillColor: Colors.white),
),
),
Container(
// height: 40,
width: constraints.maxWidth * 0.3,
color: Colors.white,
child: DropdownButtonFormField(
onChanged: (value) {},
items: _dropdownTime
.map((value) => DropdownMenuItem(
child: Text(value),
value: value,
))
.toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.watch_later_outlined, size: 16),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(16),
fillColor: Colors.white),
),
),
],
);
}
),

Related

Flutter DropdownButtonFormField selected item didn't showed up

I have some problem with my dropdown in flutter.
Here's the UI with hint :
And the when we select item from dropdown, the item selected not showed up or only show half of it.
Here's the UI after select data from dropdown :
The selected item didn't showed up normally like in the attachment above.
Here's my code :
LayoutBuilder(
builder: (context, constraints) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 40,
width: constraints.maxWidth * 0.55,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: DropdownButtonFormField(
isExpanded: true,
onChanged: (value) {},
items: _dropdownDate.map((value) =>
DropdownMenuItem(
child: Text(value),
value: value,
)).toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month, size: 16),
hintText: 'Select Date',
hintStyle: TextStyle(fontSize: 12),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(16),
fillColor: Colors.white
),
),
),
Container(
height: 40,
width: constraints.maxWidth * 0.40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: DropdownButtonFormField(
isExpanded: true,
onChanged: (value) {},
items: _dropdownTime.map((value) =>
DropdownMenuItem(
child: Text(value),
value: value,
)).toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month, size: 16),
hintText: 'Select Time',
hintStyle: TextStyle(fontSize: 12),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(16),
fillColor: Colors.white
),
),
),
],
);
}
),
I can't find a way to configure the size of font after selected.
Thank you before
Increment your container height or reduce content padding. it will help you
contentPadding: const EdgeInsets.all(3)
Decrease the contentPadding will work. in your case, you can change contentPadding.
contentPadding: const EdgeInsets.all(2),
fillColor: Colors.white
Increase the size of the container and reduces content padding. it will work
LayoutBuilder(
builder: (context, constraints) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 50,
width: constraints.maxWidth * 0.55,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: DropdownButtonFormField(
isExpanded: true,
onChanged: (value) {},
items: _dropdownDate.map((value) =>
DropdownMenuItem(
child: Text(value),
value: value,
)).toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month, size: 16),
hintText: 'Select Date',
hintStyle: TextStyle(fontSize: 12),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(10),
fillColor: Colors.white
),
),
),
Container(
height: 50,
width: constraints.maxWidth * 0.40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: DropdownButtonFormField(
isExpanded: true,
onChanged: (value) {},
items: _dropdownTime.map((value) =>
DropdownMenuItem(
child: Text(value),
value: value,
)).toList(),
elevation: 4,
dropdownColor: Colors.white,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month, size: 16),
hintText: 'Select Time',
hintStyle: TextStyle(fontSize: 12),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
width: 0.8,
color: Colors.grey,
)),
contentPadding: const EdgeInsets.all(10),
fillColor: Colors.white
),
),
),
],
);
}
),

Flutter make container transparent

Material(
elevation: 30.0,
shadowColor: Colors.grey,
child: Container(
width: 300,
child: SingleChildScrollView(
child: TextField(
controller: controller,
style: TextStyle(
color: Colors.black,
fontSize: 30,
),
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'hinttText',
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: Colors.black,
width: 2.0,
),
),
),
......................................
......................................
......................................
How do I make my flutter container color to transparent.(only the container. Not Text Field)
Use Colors.transparent this sets it to transparent
Material(
elevation: 30.0,
shadowColor: Colors.grey,
child: Container(
width: 300,
color: Colors.transparent, //<------ this line
child: SingleChildScrollView(
child: TextField(
controller: controller,
style: TextStyle(
color: Colors.black,
fontSize: 30,
),
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'hinttText',
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: Colors.black,
width: 2.0,
),
),
)
)
)
)
)

Using Positioned inside Stack is not working properly

I am using a Stack which has Card and Positioned Elements as can be seen in the below image. These Positioned Elements contains the buttons. The issue I am facing is that the lower part of these buttons are hidden.
Also I have not given any extra margin. It might be because of Bottom Navigation Part.
image
This is the code
Stack(
children: <Widget>[
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 40.0, horizontal: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.skills,
builder: (context, snapshot) {
return TextField(
onChanged: bloc.changeSkills,
decoration: new InputDecoration(
contentPadding:
EdgeInsets.symmetric(
vertical: 0,
horizontal: 15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width: 2.0,
style:
BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color:
Colors.grey,
width: 2.0),
borderRadius:
BorderRadius.circular(
50.0),
),
hintText: 'Skills',
hintStyle: new TextStyle(
color: Colors.grey,
fontWeight:
FontWeight.bold),
errorText: snapshot.error),
);
}),
),
SizedBox(height: 20.0),
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.role,
builder: (context, snapshot) {
return TextField(
onChanged: bloc.changeRole,
decoration: new InputDecoration(
contentPadding:
EdgeInsets.symmetric(
vertical: 0,
horizontal: 15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width: 2.0,
style:
BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color:
Colors.grey,
width: 2.0),
borderRadius:
BorderRadius.circular(
50.0),
),
hintText: 'Role',
hintStyle: new TextStyle(
color: Colors.grey,
fontWeight:
FontWeight.bold),
errorText: snapshot.error),
);
}),
),
],
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.language,
builder: (context, snapshot) {
return TextField(
onChanged: bloc.changeLanguage,
decoration: new InputDecoration(
contentPadding:
EdgeInsets.symmetric(
vertical: 0,
horizontal: 15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width: 2.0,
style:
BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color:
Colors.grey,
width: 2.0),
borderRadius:
BorderRadius.circular(
50.0),
),
hintText: 'Language',
hintStyle: new TextStyle(
color: Colors.grey,
fontWeight:
FontWeight.bold),
errorText: snapshot.error),
);
}),
),
SizedBox(height: 20.0),
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.gender,
builder: (context, snapshot) {
return DropdownButtonHideUnderline(
child:
new DropdownButtonFormField<
String>(
items: <String>[
'Female',
'Male',
'Other'
].map((String value) {
return new DropdownMenuItem<
String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: bloc.changeGender,
decoration:
new InputDecoration(
contentPadding:
EdgeInsets
.symmetric(
vertical:
0,
horizontal:
15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width:
2.0,
style: BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color: Colors
.grey,
width: 2.0),
borderRadius:
BorderRadius
.circular(
50.0),
),
hintText: 'Gender',
hintStyle:
new TextStyle(
color: Colors
.grey,
fontWeight:
FontWeight
.bold),
errorText:
snapshot.error),
),
);
}),
)
],
),
),
],
),
),
),
Positioned(
left: size.width * 0.02,
top: size.height * 0.58 + 2,
child: new Container(
width: 100.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50.0),
color: Colors.white,
border: Border.all(
width: 2.0, color: Colors.grey)),
child: Align(
alignment: Alignment.center,
child: new Text(
'Back',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold),
),
),
)),
Positioned(
right: size.width * 0.02,
top: size.height * 0.58 + 2,
child: new Container(
width: 100.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50.0),
color: primaryColor,
// border: Border.all(width: 2.0, color: Colors.grey)
),
child: Align(
alignment: Alignment.center,
child: new Text(
'Create',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
)),
],
),
Add overflow: Overflow.visible, to the Stack

flutter (ui design) my text field adjust badly to its parent container

Hi im trying to make a responsive ui, so I adjust my width & height thoroughly with mediaquery.of(context).size. Now, the problem I've been currently dealing with is that my textfield does not exactly adjust wisely with its parent container leaving the text raised.
my code:
import 'package:flutter/material.dart';
class LoginUI {
LoginUI(this.myClipper, this.myBGClipperColor, this.myColorLightOrange);
final Color myColorLightOrange;
final Color myBGClipperColor;
final CustomClipper myClipper;
Widget getLoginUIWidget() {
return Builder(builder: (BuildContext context) {
Size mediaSize = MediaQuery.of(context).size;
return Container(
width: mediaSize.width,
height: mediaSize.height,
color: Colors.white,
child: Stack(
children: <Widget>[
ClipPath(
child: Container(
color: myBGClipperColor,
),
clipper: myClipper,
),
Text("\n Login",
style: TextStyle(
color: Colors.white,
fontSize: 23,
fontWeight: FontWeight.bold)),
Container(
width: mediaSize.width * .8,
height: mediaSize.height * .8,
margin: EdgeInsets.fromLTRB(
mediaSize.width * .1,
mediaSize.height * .23,
mediaSize.width * .1,
mediaSize.height * .1),
color: Colors.transparent,
child: Column(
children: <Widget>[
Container(
height: mediaSize.height * .25,
width: mediaSize.width * .8,
child: Image.asset(
'assets/images/image_pushing_cart.png',
fit: BoxFit.fill,
)),
**Container(
constraints:
BoxConstraints(maxHeight: mediaSize.height * .070),
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black54.withOpacity(0.45),
spreadRadius: 1,
blurRadius: 4,
offset: Offset(3.5, 4))
]),
child: TextFormField(
textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.transparent),
borderRadius:
BorderRadius.all(Radius.circular(20))),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.transparent),
borderRadius:
BorderRadius.all(Radius.circular(20))),
hintText: "Email",
hintStyle: TextStyle(color: Colors.black87),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.teal,
),
),
prefixIcon: Icon(
Icons.person,
color: Colors.black54,
),
filled: true,
fillColor: myColorLightOrange),
style: TextStyle(color: Colors.black),
),
),**
Text("\n"),
**Container(
constraints:
BoxConstraints(maxHeight: mediaSize.height * .070),
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black54.withOpacity(0.45),
spreadRadius: 1,
blurRadius: 4,
offset: Offset(3.5, 4))
]),
child: TextFormField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.transparent),
borderRadius:
BorderRadius.all(Radius.circular(20))),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.transparent),
borderRadius:
BorderRadius.all(Radius.circular(20))),
prefixIcon: Icon(
Icons.enhanced_encryption,
color: Colors.black54,
),
hintText: "********",
filled: true,
fillColor: myColorLightOrange),
style: TextStyle(color: Colors.black),
))**
],
),
)
],
),
);
});
}
}
Here is an image example
Is there a possibility that textfield would adjust accordingly whichever I gave its parent's (Container) width and height.
Try removing this line.
textAlignVertical: TextAlignVertical.center,
To apply the padding to the content of the TextField. You can apply this code contentPadding property ,TextAlign property and also add
isDense can be use for precise padding
new TextField(
textAlign: TextAlign.left,
decoration: new InputDecoration(isDense: true,,hintText: "Email", contentPadding:
const EdgeInsets.all(20.0))
)

Flutter| While keyboard pops up there will be BottomOverFlowed. Need exact design as shown in image

When keyboard pops up, there will be bottom over flowed. I need to add a expanded card as background for login form and submit button.
And also need that expanded card to move up when there is keyboard.
I have checked through many other solution for keyboard popup, but I couldn't get exact solution for mine design.
return new Scaffold(
body: new Column(children: <Widget>[
SizedBox(
height: 70,
),
new Image.asset(
'assets/logo.png',
fit: BoxFit.cover,
),
new Text(
"Login",
style: TextStyle(fontSize: 20, color: Colors.white),
),
new Text(
"It has noon , but also the Type roman, remaining essentially unchanged for the wish i could do.",
textAlign: TextAlign.center,
),
Column(
children: <Widget>[
Expanded(
child: Container(
child: Container(
padding: EdgeInsets.all(24),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(25.0),
topRight: const Radius.circular(25.0))),
child: new ListView(
children: <Widget>[
TextField(
style: new TextStyle(
color: Color(0xff651515),
),
autofocus: false,
obscureText: false,
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: "email",
hintText: "email",
labelStyle: TextStyle(
color: Color(0xffa4a4a4),
fontSize: 14,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
borderSide: BorderSide(
width: 2,
color: Color(0xff55c882),
style: BorderStyle.solid),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
borderSide: BorderSide(
width: 1,
color: Color(0xffa4a4a4),
),
),
),
),
SizedBox(
height: 20,
),
TextField(
style: new TextStyle(
color: Color(0xff651515),
),
autofocus: false,
obscureText: false,
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: "password",
hintText: "password",
labelStyle: TextStyle(
color: Color(0xffa4a4a4),
fontSize: 14,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
borderSide: BorderSide(
width: 2,
color: Color(0xff55c882),
style: BorderStyle.solid),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
borderSide: BorderSide(
width: 1,
color: Color(0xffa4a4a4),
),
),
),
),
],
),
),
))
],
)
]));
you can just wrap your column with a:
SingleChildScrollView(
child: put your column here
)
hope it helped