-
Notifications
You must be signed in to change notification settings - Fork 106
/
media_query.dart
130 lines (121 loc) · 4.01 KB
/
media_query.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/material.dart';
import 'diagram_step.dart';
class MediaQueryDiagram extends StatefulWidget with DiagramMetadata {
const MediaQueryDiagram({super.key, required this.name});
@override
final String name;
@override
State<MediaQueryDiagram> createState() => _MediaQueryDiagramState();
}
class _MediaQueryDiagramState extends State<MediaQueryDiagram> {
@override
Widget build(BuildContext context) {
return ConstrainedBox(
key: UniqueKey(),
constraints: BoxConstraints.tight(const Size(
500.0,
300.0,
)),
child: Theme(
data: ThemeData(
primarySwatch: Colors.blue,
),
child: Material(
color: const Color(0xFFFFFFFF),
child: MediaQuery(
data: const MediaQueryData(),
child: Center(
child: Stack(
alignment: Alignment.topCenter,
children: <Widget>[
Container(
width: 350.0,
height: 250.0,
color: Colors.black,
),
Container(
width: 342.0,
height: 246.0,
color: Colors.red,
),
Padding(
padding: const EdgeInsets.only(bottom: 130.0),
child: Container(
width: 342.0,
height: 246.0,
color: Colors.amber,
),
),
Padding(
padding: const EdgeInsets.only(bottom: 200.0),
child: Container(
width: 342.0,
height: 246.0,
color: Colors.white,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0.0, 170, 240.0, 0.0),
child: Container(
width: 6.0,
height: 80.0,
color: Colors.black45,
),
),
const Padding(
padding: EdgeInsets.fromLTRB(0.0, 260, 240.0, 0.0),
child: Text(
'viewInsets',
style: TextStyle(fontSize: 20.0),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0.0, 100, 0.0, 0.0),
child: Container(
width: 6.0,
height: 70.0,
color: Colors.black45,
),
),
const Padding(
padding: EdgeInsets.fromLTRB(0.0, 70, 0.0, 0.0),
child: Text(
'padding',
style: TextStyle(fontSize: 20.0),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(240.0, 100.0, 0.0, .0),
child: Container(
width: 6.0,
height: 150.0,
color: Colors.black45,
),
),
const Padding(
padding: EdgeInsets.fromLTRB(240.0, 260.0, 0.0, 0.0),
child: Text(
'viewPadding',
style: TextStyle(fontSize: 20.0),
),
),
],
),
),
),
),
),
);
}
}
class MediaQueryDiagramStep extends DiagramStep {
@override
final String category = 'widgets';
@override
Future<List<MediaQueryDiagram>> get diagrams async =>
<MediaQueryDiagram>[const MediaQueryDiagram(name: 'media_query')];
}