forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstrained_box.dart
58 lines (56 loc) · 1.82 KB
/
constrained_box.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
import 'package:flutter/material.dart';
class MyConstrainedBox extends StatelessWidget {
const MyConstrainedBox({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('ConstrainedBox')),
body: Center(
child: Column(
children: [
const SizedBox(height: 20),
ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 200,
maxWidth: 300,
minHeight: 200,
maxHeight: 300,
),
child: Container(
height: 500, //300
width: 500, //300
color: Colors.red,
alignment: Alignment.center,
child: const Text(
"It's using the maxWidth & maxHeight if the ConstrainedBox\n300 x 300",
style: TextStyle(color: Colors.white, fontSize: 25),
textAlign: TextAlign.center,
),
),
),
const SizedBox(height: 40),
ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 200,
maxWidth: 300,
minHeight: 200,
maxHeight: 300,
),
child: Container(
height: 100, // 200
width: 100, // 200
color: Colors.red,
alignment: Alignment.center,
child: const Text(
"It's using the minWidth & minHeight if the ConstrainedBox\n200 x 200",
style: TextStyle(color: Colors.white, fontSize: 20),
textAlign: TextAlign.center,
),
),
),
],
),
),
);
}
}