forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout_builder.dart
67 lines (63 loc) · 1.93 KB
/
layout_builder.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
import 'package:flutter/material.dart';
class MyLayoutBuilder extends StatefulWidget {
const MyLayoutBuilder({Key? key}) : super(key: key);
@override
State<MyLayoutBuilder> createState() => _MyLayoutBuilderState();
}
class _MyLayoutBuilderState extends State<MyLayoutBuilder> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Layout Builder (run in chrome)')),
body: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
// final width = constraints.maxWidth;
// final height = constraints.maxHeight;
if (constraints.maxWidth < 600) {
///
/// This is the `mobile` version view
///
return Container(
color: Colors.red,
child: const Center(
child: Text(
'CONTENT',
style: TextStyle(color: Colors.white, fontSize: 30),
),
),
);
} else {
///
/// This is the `desktop` version view
///
return Row(
children: [
Container(
color: Colors.blue,
width: 250,
child: const Center(
child: Text(
'SIDEBAR',
style: TextStyle(color: Colors.white, fontSize: 30),
),
),
),
Expanded(
child: Container(
color: Colors.red,
child: const Center(
child: Text(
'CONTENT',
style: TextStyle(color: Colors.white, fontSize: 30),
),
),
),
),
],
);
}
},
),
);
}
}