-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathday039_limited_box.dart
77 lines (75 loc) · 2.58 KB
/
day039_limited_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class Day39LimitedBox extends StatelessWidget {
const Day39LimitedBox({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
/**
* ? What is LimitedBox....
* ! LimitedBox is the setting up the size of the child Widget if parent Widget is non constrained....
* ! Best example of LimitedBox is for controlling the size of ListView items.....
* ! because ListView items don't follow any constraines....
*/
return Scaffold(
body: SafeArea(
child: Center(
child: Stack(
alignment: Alignment.center,
children: <Widget>[
/**
* ! you can see that LimitedBox is not works on the Container or any constrained boxes....
* ! it will works only in some Unconstrained spaces like UnconstrainedBox, ListView....
*/
Container(
width: 300,
height: 300,
child: LimitedBox(
/**
* ! here the LimitedBox size in useless bcos Parent Container have it's own width and height....
*/
maxWidth: 150,
maxHeight: 150,
child: Container(
color: Colors.red,
),
),
),
UnconstrainedBox(
// ! here I added the UnconstrainedBox which is dont have any width and height....
child: LimitedBox(
maxWidth: 150,
maxHeight: 150,
child: Container(
/**
* ! so, The with and height of the Container is fixed to the it's parent LimitedBox
*/
color: Colors.amber,
),
),
),
],
),
),
),
appBar: AppBar(
title: Text("LimitedBox"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.help),
onPressed: () async {
const url =
'https://github.com/sanjaysanju618/100-Days-Of-Flutter-Widgets/' +
'blob/master/hundred_days_of_flutter_widget/' +
'lib/day039_limited_box.dart';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
)
],
),
);
}
}