forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmediaquery.dart
39 lines (37 loc) · 1.22 KB
/
mediaquery.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import 'package:flutter/material.dart';
class MyMediaQuery extends StatelessWidget {
const MyMediaQuery({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Media Query")),
backgroundColor: Colors.deepPurple[100],
body: Center(
child: Column(
//crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'Height: ' + MediaQuery.of(context).size.height.toString(),
style: const TextStyle(fontSize: 24),
),
Text(
'Width: ' + MediaQuery.of(context).size.width.toString(),
style: const TextStyle(fontSize: 24),
),
Text(
'Aspect Ratio: ' +
MediaQuery.of(context).size.aspectRatio.toStringAsFixed(2),
style: const TextStyle(fontSize: 24),
),
// for orientation
Text(
"Orientation: " + MediaQuery.of(context).orientation.toString(),
style: const TextStyle(fontSize: 24),
),
],
),
),
);
}
}