Skip to content

Commit 5890007

Browse files
Add files via upload
1 parent 60cce13 commit 5890007

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

main.dart

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import 'package:flutter/material.dart';
2+
3+
void main() {
4+
runApp(const MyApp());
5+
}
6+
7+
class MyApp extends StatelessWidget {
8+
const MyApp({super.key});
9+
10+
@override
11+
Widget build(BuildContext context) {
12+
return const MaterialApp(
13+
title: 'layout Builder',
14+
home: MyStateLessClass(),
15+
);
16+
}
17+
}
18+
19+
class MyStateLessClass extends StatelessWidget {
20+
const MyStateLessClass({super.key});
21+
22+
@override
23+
Widget build(BuildContext context) {
24+
return Scaffold(
25+
appBar: AppBar(
26+
title: const Text(
27+
'Responsive Layout',
28+
),
29+
backgroundColor: const Color.fromARGB(255, 255, 142, 4),
30+
),
31+
body: LayoutBuilder(
32+
builder: (BuildContext context, BoxConstraints constraints) {
33+
if (constraints.maxWidth > 600) {
34+
return buildWideContainer();
35+
} else {
36+
return buildnarrowContainer();
37+
}
38+
},
39+
),
40+
);
41+
}
42+
43+
Widget buildnarrowContainer() {
44+
return Center(
45+
child: Container(
46+
height: 400,
47+
width: 300,
48+
// color: Colors.red,
49+
child: Image.asset(
50+
'/Users/iphtech30/Desktop/test/flutter/images/img.jpeg'),
51+
),
52+
);
53+
}
54+
55+
Widget buildWideContainer() {
56+
return Center(
57+
child: Row(
58+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
59+
children: <Widget>[
60+
SizedBox(
61+
height: 400,
62+
width: 300,
63+
child: Image.asset(
64+
'/Users/iphtech30/Desktop/test/flutter/images/game.jpeg'),
65+
),
66+
SizedBox(
67+
height: 400,
68+
width: 300,
69+
// color: Colors.yellow,
70+
child: Image.asset(
71+
'/Users/iphtech30/Desktop/test/flutter/images/game.webp'),
72+
)
73+
],
74+
),
75+
);
76+
}
77+
}

0 commit comments

Comments
 (0)