Last active
January 29, 2021 13:46
-
-
Save felipecastrosales/6d5967c2ca74d9505b0848d8239bf307 to your computer and use it in GitHub Desktop.
MediaQuery 02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: MediaQueryExample02(), | |
); | |
} | |
} | |
class MediaQueryExample02 extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.black, | |
body: Center( | |
child: Container( | |
width: MediaQuery.of(context).size.width * 0.5, | |
height: MediaQuery.of(context).size.height * 0.75, | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
color: Colors.blue, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment