Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Last active January 29, 2021 13:46
Show Gist options
  • Save felipecastrosales/6d5967c2ca74d9505b0848d8239bf307 to your computer and use it in GitHub Desktop.
Save felipecastrosales/6d5967c2ca74d9505b0848d8239bf307 to your computer and use it in GitHub Desktop.
MediaQuery 02
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