Friday, August 7, 2020

Safe Area Widget || Flutter

Safe Area Widget 
...........................................................................................................................................................................................................................


...........................................................................................................................................................................................................................


Happy Coding :)
...........................................................................................................................................................................................................................


Happy Coding :)
...........................................................................................................................................................................................................................
Example : #1[Safe area]

import 'package:flutter/material.dart';
void main()=>runApp(MaterialApp(home: MyApp(),));

class MyApp extends StatefulWidget{
@override
MyAppState createState()=>MyAppState();
}
class MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context){
return SafeArea(
child: Scaffold(
body:
Center(
child:
Container(
color: Colors.
red,
)
),
),
);
}
}

Happy Coding :)
...........................................................................................................................................................................................................................
Example : #2[MediaQuery ]
import 'package:flutter/material.dart';
void main()=>runApp(MaterialApp(home: MyApp(),));

class MyApp extends StatefulWidget{
@override
MyAppState createState()=>MyAppState();
}
class MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context){
EdgeInsets devicePadding = MediaQuery.of(context).viewPadding;
return Padding(
padding: devicePadding,
child:
Scaffold(
body:
Center(
child:
Container(
color: Colors.
red,
)
),
),
);
}
}
Happy Coding :)
...........................................................................................................................................................................................................................
Example : #3[Safe area]


Happy Coding :)
...........................................................................................................................................................................................................................



...........................................................................................................................................................................................................................


...........................................................................................................................................................................................................................



...........................................................................................................................................................................................................................



...........................................................................................................................................................................................................................


...........................................................................................................................................................................................................................




No comments:

Post a Comment