Skip to content

Commit 6a6755a

Browse files
committed
✨ Bad Code Example
1 parent 0701709 commit 6a6755a

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

lib/bad_example.dart

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import 'package:flutter/material.dart';
2+
3+
class BadFlutterExample extends StatelessWidget {
4+
// Many parameters
5+
void doSomething(int a, int b, int c, int d, int e) {
6+
if (e > 100) return;
7+
if (a > 0) {
8+
if (b > 0) {
9+
if (c > 0) {
10+
if (d > 0) {
11+
print('All positive');
12+
} else {
13+
print('d is not positive');
14+
}
15+
} else {
16+
print('c is not positive');
17+
}
18+
} else {
19+
print('b is not positive');
20+
}
21+
} else {
22+
print('a is not positive');
23+
}
24+
}
25+
26+
void method1() {
27+
print('method1');
28+
}
29+
30+
void method2() {
31+
print('method2');
32+
}
33+
34+
void method3() {
35+
print('method3');
36+
}
37+
38+
void method4() {
39+
print('method4');
40+
}
41+
42+
void method5() {
43+
print('method5');
44+
}
45+
46+
void method6() {
47+
print('method6');
48+
}
49+
50+
void method7() {
51+
print('method7');
52+
}
53+
54+
void method8() {
55+
print('method8');
56+
}
57+
58+
void method9() {
59+
print('method9');
60+
}
61+
62+
void method10() {
63+
print('method10');
64+
}
65+
66+
void complexMethod() {
67+
doSomething(1, 2, 3, 4, 5);
68+
method1();
69+
method2();
70+
method3();
71+
method4();
72+
method5();
73+
method6();
74+
method7();
75+
method8();
76+
method9();
77+
method10();
78+
doSomething(1, 2, 3, 4, 5);
79+
doSomething(1, 2, 3, 4, 5);
80+
}
81+
82+
@override
83+
Widget build(BuildContext context) {
84+
return Scaffold(
85+
appBar: AppBar(
86+
title: Text('Bad Flutter Example'),
87+
),
88+
body: SingleChildScrollView(
89+
child: Column(
90+
children: [
91+
for (int i = 0; i < 10; i++)
92+
Container(
93+
margin: EdgeInsets.all(10),
94+
child: Column(
95+
children: [
96+
Row(
97+
children: [
98+
Text('Item $i'),
99+
Icon(Icons.star),
100+
ElevatedButton(
101+
onPressed: () {},
102+
child: Text('Button $i'),
103+
),
104+
],
105+
),
106+
],
107+
),
108+
),
109+
Text('Counter: 0'),
110+
ElevatedButton(
111+
onPressed: () {
112+
complexMethod();
113+
},
114+
child: Text('Do Something'),
115+
),
116+
for (int i = 0; i < 10; i++)
117+
Container(
118+
margin: EdgeInsets.all(10),
119+
child: Column(
120+
children: [
121+
Row(
122+
children: [
123+
Text('Item $i'),
124+
Icon(Icons.star),
125+
ElevatedButton(
126+
onPressed: () {},
127+
child: Text('Button $i'),
128+
),
129+
],
130+
),
131+
],
132+
),
133+
),
134+
],
135+
),
136+
),
137+
);
138+
}
139+
140+
void test() {
141+
method1();
142+
method2();
143+
method3();
144+
method4();
145+
method5();
146+
}
147+
}

0 commit comments

Comments
 (0)