-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathday002_expanded.dart
92 lines (90 loc) · 3.37 KB
/
day002_expanded.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
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class Day2Expanded extends StatelessWidget {
const Day2Expanded({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
bool isExpanded =
true; // ! change this to true to see the expanded funtionality....
return Scaffold(
appBar: AppBar(
title: Text("Expanded"),
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/day002_expanded.dart';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
)
],
),
body: SafeArea(
child: Container(
child: isExpanded
? Column(
/**
* ! This Column use the Expanded Widget to share the children spaces in screen....
* ! Expanded uses the [flex] propertie to give the spacing level....
* ! play with [flex] to see the changes....
* ! initialy [flex] have 1....
* ! Creates a widget that expands a child of a Row,Column or Flex....
*/
children: <Widget>[
Expanded(
flex: 10, // ? It will take 10% of screen
child: Container(
color: Colors.red,
),
),
Expanded(
flex: 80, // ? It will take 80% of screen
child: Container(
color: Colors.green,
),
),
Expanded(
flex: 10, // ? It will take 10% of screen
child: Container(
color: Colors.yellow,
),
),
],
)
: Column(
/**
* ! This Column don't use the Expanded Widget instead we used the MediaQuery to share the spaces....
* ! play with [height] to see the changes....
*/
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height *
0.30, // ? 30% of the screen
color: Colors.red,
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height *
0.30, // ? 30% of the screen
color: Colors.green,
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height *
0.30, // ? 30% of the screen
color: Colors.yellow,
),
],
),
),
),
);
}
}