In Ui margin, padding, text and image sizes are given constant values. I didn't use Fractional box
and Constraint box
etc..I need to set according to the screen size via media query
I used media query like this but unable to set properly.
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
double height35 = height * 0.35;
if my padding is padding:const EdgeInsets.only(left: 25.0,right: 25.0)
, how can i set padding and other fixed size from media query. Here 1, Here 2
are the doc and example but did't not get way from media query..
I have used this library too but it is not as effective as I want.
here is my code.
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
MediaQueryData queryData;
queryData = MediaQuery.of(context);
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
double height35 = height * 0.35;
return Scaffold(
body: Container(
decoration: BoxDecoration(color: Color(0xFFE7F6FD)),
child: Column(
children: <Widget>[
SizedBox(height: height35,),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
height: 50.0,
child: IconButton(icon: Icon(Icons.close,color: Color(0xFF005283),size: 36.0,), onPressed: null),
),
],),
Container(child: SingleChildScrollView(
padding:const EdgeInsets.only(left: 25.0,right: 25.0),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
height: 60.0,
child: Image.asset('assets/images/login_logo.png')),
SizedBox(
height: 30.0,
),
TextFormField(
style: new TextStyle(fontSize:18.0,color: Color(0xFF005283)),
decoration: InputDecoration(
// prefixIcon: Icon(Icons.email, color: Colors.grey),
enabledBorder: UnderlineInputBorder(borderSide: new BorderSide(color: Color(0xFF005283))),
hintStyle: TextStyle(color: Color(0xFF005283),fontSize:18.0,fontFamily: "WorkSansLight"),
hintText: 'Email/Mobile No.'),
),
SizedBox(
height: 30.0,
),
TextFormField(
style: new TextStyle(fontSize:18.0,color: Color(0xFF005283)),
obscureText: true,
decoration: InputDecoration(
// prefixIcon: Icon(Icons.email, color: Colors.grey),
labelStyle: new TextStyle(color: Colors.blue),
enabledBorder: UnderlineInputBorder(borderSide: new BorderSide(color: Color(0xFF005283))),
hintStyle: TextStyle(color: Color(0xFF005283),fontSize:18.0,fontFamily: "WorkSansLight"),
hintText: 'Password'),
),
SizedBox(
height: 30.0,
),
RaisedButton(
onPressed: () {
},
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(60.0)),
child: Padding(
padding: EdgeInsets.only(top:18.0,bottom: 18.0,left: 10.0,right: 10.0),
child: Text('LOG IN',style: new TextStyle(fontSize:18.0,color: Color(0xFF005283),fontFamily: "WorkSansMedium"),)),
color: Color(0xFFc1ff02),
textColor: Colors.white,),
SizedBox(
height: 30.0,),
Row(
children: <Widget>[
Expanded(
child: Divider(
color: Color(0xFF005283),
height: 8.0,
),
),
SizedBox(
width: 8.0,
),
Text(
'OR CONNECT WITH',
style: TextStyle(fontSize:14.0,color: Color(0xFF005283),fontFamily: "WorkSansLight",fontWeight: FontWeight.normal),
),
SizedBox(
width: 8.0,
),
Expanded(
child: Divider(
color: Color(0xFF005283),
height: 8.0,
),
)
],
),
Row(
children: <Widget>[
FlatButton.icon(
onPressed: null,
label: Text('Login with Facebook',style: TextStyle(color: Colors.white),),
icon: Icon(Icons.local_gas_station,color: Colors.white,),
shape: Border.all(color: Colors.grey,width: 2.0,style: BorderStyle.none ),
//shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0),)
),
OutlineButton(
color: Colors.black,
child: new Text("Button text"),
onPressed: null,
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0))
),
],
),
SizedBox(
height: 20.0,
),
Center(
child: GestureDetector(
onTap: () {
Navigator.pushNamed(context, "myRoute");
},
child: RichText(
text: new TextSpan(
children: <TextSpan>[
TextSpan(text:'Not a Member? ',style: TextStyle(color: Color(0xFF005283),fontSize: 14.0,fontWeight: FontWeight.w400),),
TextSpan(text:'Register Now',style: TextStyle(color: Color(0xFF005283),fontSize: 18.0,fontWeight: FontWeight.w600),),
],
),
),
) ,
),
SizedBox(
height: 20.0,
),
OutlineButton(
color: Color(0xFF005283),
child: new Text("CONTINUE AS GUEST",style: TextStyle(color: Color(0xFF005283),fontSize: 14.0,)),
onPressed: null,
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0))
),
],),))
],
),
),
);
}
}