Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80cf263

Browse files
committed
Update all samples broken styles
1 parent 8cbaae9 commit 80cf263

15 files changed

+426
-377
lines changed

example/lib/bar_chart/samples/bar_chart_sample1.dart

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -260,37 +260,42 @@ class BarChartSample1State extends State<BarChartSample1> {
260260
enabled: false,
261261
),
262262
titlesData: FlTitlesData(
263-
show: true,
264-
bottomTitles: SideTitles(
265-
showTitles: true,
266-
getTextStyles: (context, value) =>
267-
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14),
268-
margin: 16,
269-
getTitles: (double value) {
270-
switch (value.toInt()) {
271-
case 0:
272-
return 'M';
273-
case 1:
274-
return 'T';
275-
case 2:
276-
return 'W';
277-
case 3:
278-
return 'T';
279-
case 4:
280-
return 'F';
281-
case 5:
282-
return 'S';
283-
case 6:
284-
return 'S';
285-
default:
286-
return '';
287-
}
288-
},
289-
),
290-
leftTitles: SideTitles(
291-
showTitles: false,
292-
),
293-
),
263+
show: true,
264+
bottomTitles: SideTitles(
265+
showTitles: true,
266+
getTextStyles: (context, value) =>
267+
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14),
268+
margin: 16,
269+
getTitles: (double value) {
270+
switch (value.toInt()) {
271+
case 0:
272+
return 'M';
273+
case 1:
274+
return 'T';
275+
case 2:
276+
return 'W';
277+
case 3:
278+
return 'T';
279+
case 4:
280+
return 'F';
281+
case 5:
282+
return 'S';
283+
case 6:
284+
return 'S';
285+
default:
286+
return '';
287+
}
288+
},
289+
),
290+
leftTitles: SideTitles(
291+
showTitles: false,
292+
),
293+
topTitles: SideTitles(
294+
showTitles: false,
295+
),
296+
rightTitles: SideTitles(
297+
showTitles: false,
298+
)),
294299
borderData: FlBorderData(
295300
show: false,
296301
),
@@ -321,6 +326,7 @@ class BarChartSample1State extends State<BarChartSample1> {
321326
return throw Error();
322327
}
323328
}),
329+
gridData: FlGridData(show: false),
324330
);
325331
}
326332

example/lib/bar_chart/samples/bar_chart_sample2.dart

Lines changed: 88 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -83,106 +83,103 @@ class BarChartSample2State extends State<BarChartSample2> {
8383
height: 38,
8484
),
8585
Expanded(
86-
child: Padding(
87-
padding: const EdgeInsets.symmetric(horizontal: 8.0),
88-
child: BarChart(
89-
BarChartData(
90-
maxY: 20,
91-
barTouchData: BarTouchData(
92-
touchTooltipData: BarTouchTooltipData(
93-
tooltipBgColor: Colors.grey,
94-
getTooltipItem: (_a, _b, _c, _d) => null,
95-
),
96-
touchCallback: (FlTouchEvent event, response) {
97-
if (response == null || response.spot == null) {
98-
setState(() {
99-
touchedGroupIndex = -1;
100-
showingBarGroups = List.of(rawBarGroups);
101-
});
102-
return;
103-
}
104-
105-
touchedGroupIndex = response.spot!.touchedBarGroupIndex;
106-
86+
child: BarChart(
87+
BarChartData(
88+
maxY: 20,
89+
barTouchData: BarTouchData(
90+
touchTooltipData: BarTouchTooltipData(
91+
tooltipBgColor: Colors.grey,
92+
getTooltipItem: (_a, _b, _c, _d) => null,
93+
),
94+
touchCallback: (FlTouchEvent event, response) {
95+
if (response == null || response.spot == null) {
10796
setState(() {
108-
if (!event.isInterestedForInteractions) {
109-
touchedGroupIndex = -1;
110-
showingBarGroups = List.of(rawBarGroups);
111-
return;
112-
}
97+
touchedGroupIndex = -1;
11398
showingBarGroups = List.of(rawBarGroups);
114-
if (touchedGroupIndex != -1) {
115-
var sum = 0.0;
116-
for (var rod in showingBarGroups[touchedGroupIndex].barRods) {
117-
sum += rod.y;
118-
}
119-
final avg =
120-
sum / showingBarGroups[touchedGroupIndex].barRods.length;
99+
});
100+
return;
101+
}
121102

122-
showingBarGroups[touchedGroupIndex] =
123-
showingBarGroups[touchedGroupIndex].copyWith(
124-
barRods: showingBarGroups[touchedGroupIndex].barRods.map((rod) {
125-
return rod.copyWith(y: avg);
126-
}).toList(),
127-
);
103+
touchedGroupIndex = response.spot!.touchedBarGroupIndex;
104+
105+
setState(() {
106+
if (!event.isInterestedForInteractions) {
107+
touchedGroupIndex = -1;
108+
showingBarGroups = List.of(rawBarGroups);
109+
return;
110+
}
111+
showingBarGroups = List.of(rawBarGroups);
112+
if (touchedGroupIndex != -1) {
113+
var sum = 0.0;
114+
for (var rod in showingBarGroups[touchedGroupIndex].barRods) {
115+
sum += rod.y;
128116
}
129-
});
130-
}),
131-
titlesData: FlTitlesData(
132-
show: true,
133-
rightTitles: SideTitles(showTitles: false),
134-
topTitles: SideTitles(showTitles: false),
135-
bottomTitles: SideTitles(
136-
showTitles: true,
137-
getTextStyles: (context, value) => const TextStyle(
138-
color: Color(0xff7589a2), fontWeight: FontWeight.bold, fontSize: 14),
139-
margin: 20,
140-
getTitles: (double value) {
141-
switch (value.toInt()) {
142-
case 0:
143-
return 'Mn';
144-
case 1:
145-
return 'Te';
146-
case 2:
147-
return 'Wd';
148-
case 3:
149-
return 'Tu';
150-
case 4:
151-
return 'Fr';
152-
case 5:
153-
return 'St';
154-
case 6:
155-
return 'Sn';
156-
default:
157-
return '';
117+
final avg = sum / showingBarGroups[touchedGroupIndex].barRods.length;
118+
119+
showingBarGroups[touchedGroupIndex] =
120+
showingBarGroups[touchedGroupIndex].copyWith(
121+
barRods: showingBarGroups[touchedGroupIndex].barRods.map((rod) {
122+
return rod.copyWith(y: avg);
123+
}).toList(),
124+
);
158125
}
159-
},
160-
),
161-
leftTitles: SideTitles(
162-
showTitles: true,
163-
getTextStyles: (context, value) => const TextStyle(
164-
color: Color(0xff7589a2), fontWeight: FontWeight.bold, fontSize: 14),
165-
margin: 32,
166-
reservedSize: 14,
167-
getTitles: (value) {
168-
if (value == 0) {
169-
return '1K';
170-
} else if (value == 10) {
171-
return '5K';
172-
} else if (value == 19) {
173-
return '10K';
174-
} else {
126+
});
127+
}),
128+
titlesData: FlTitlesData(
129+
show: true,
130+
rightTitles: SideTitles(showTitles: false),
131+
topTitles: SideTitles(showTitles: false),
132+
bottomTitles: SideTitles(
133+
showTitles: true,
134+
getTextStyles: (context, value) => const TextStyle(
135+
color: Color(0xff7589a2), fontWeight: FontWeight.bold, fontSize: 14),
136+
margin: 20,
137+
getTitles: (double value) {
138+
switch (value.toInt()) {
139+
case 0:
140+
return 'Mn';
141+
case 1:
142+
return 'Te';
143+
case 2:
144+
return 'Wd';
145+
case 3:
146+
return 'Tu';
147+
case 4:
148+
return 'Fr';
149+
case 5:
150+
return 'St';
151+
case 6:
152+
return 'Sn';
153+
default:
175154
return '';
176-
}
177-
},
178-
),
155+
}
156+
},
179157
),
180-
borderData: FlBorderData(
181-
show: false,
158+
leftTitles: SideTitles(
159+
showTitles: true,
160+
getTextStyles: (context, value) => const TextStyle(
161+
color: Color(0xff7589a2), fontWeight: FontWeight.bold, fontSize: 14),
162+
margin: 8,
163+
reservedSize: 28,
164+
interval: 1,
165+
getTitles: (value) {
166+
if (value == 0) {
167+
return '1K';
168+
} else if (value == 10) {
169+
return '5K';
170+
} else if (value == 19) {
171+
return '10K';
172+
} else {
173+
return '';
174+
}
175+
},
182176
),
183-
barGroups: showingBarGroups,
184-
gridData: FlGridData(show: false),
185177
),
178+
borderData: FlBorderData(
179+
show: false,
180+
),
181+
barGroups: showingBarGroups,
182+
gridData: FlGridData(show: false),
186183
),
187184
),
188185
),

example/lib/bar_chart/samples/bar_chart_sample3.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class _BarChart extends StatelessWidget {
7373
},
7474
),
7575
leftTitles: SideTitles(showTitles: false),
76+
topTitles: SideTitles(showTitles: false),
77+
rightTitles: SideTitles(showTitles: false),
7678
);
7779

7880
FlBorderData get borderData => FlBorderData(

example/lib/bar_chart/samples/bar_chart_sample4.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@ class BarChartSample4State extends State<BarChartSample4> {
5353
),
5454
leftTitles: SideTitles(
5555
showTitles: true,
56+
reservedSize: 40,
5657
getTextStyles: (context, value) => const TextStyle(
5758
color: Color(
5859
0xff939393,
5960
),
6061
fontSize: 10),
6162
margin: 0,
6263
),
64+
topTitles: SideTitles(showTitles: false),
65+
rightTitles: SideTitles(showTitles: false),
6366
),
6467
gridData: FlGridData(
6568
show: true,

example/lib/line_chart/line_chart_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class LineChartPage extends StatelessWidget {
4545
padding: const EdgeInsets.only(left: 28.0, right: 28),
4646
child: LineChartSample2(),
4747
),
48+
SizedBox(height: 22),
4849
],
4950
),
5051
);

example/lib/line_chart/line_chart_page2.dart

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,26 @@ import 'samples/line_chart_sample8.dart';
99
class LineChartPage2 extends StatelessWidget {
1010
@override
1111
Widget build(BuildContext context) {
12-
return Container(
13-
color: Colors.white,
14-
child: Center(
15-
child: Padding(
16-
padding: const EdgeInsets.symmetric(horizontal: 20),
17-
child: ListView(
18-
children: <Widget>[
19-
const Text(
20-
'LineChart',
21-
style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold, color: Colors.black),
22-
),
23-
LineChartSample3(),
24-
LineChartSample4(),
25-
LineChartSample7(),
26-
LineChartSample5(),
27-
LineChartSample8(),
28-
],
12+
return DefaultTextStyle(
13+
style: TextStyle(color: Colors.black, fontSize: 12),
14+
child: Container(
15+
color: Colors.white,
16+
child: Center(
17+
child: Padding(
18+
padding: const EdgeInsets.symmetric(horizontal: 20),
19+
child: ListView(
20+
children: <Widget>[
21+
const Text(
22+
'LineChart',
23+
style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold, color: Colors.black),
24+
),
25+
LineChartSample3(),
26+
LineChartSample4(),
27+
LineChartSample7(),
28+
LineChartSample5(),
29+
LineChartSample8(),
30+
],
31+
),
2932
),
3033
),
3134
),

example/lib/line_chart/samples/line_chart_sample1.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class _LineChart extends StatelessWidget {
109109
getTitles: getTitles,
110110
showTitles: true,
111111
margin: 8,
112-
reservedSize: 30,
112+
interval: 1,
113+
reservedSize: 40,
113114
getTextStyles: (context, value) => const TextStyle(
114115
color: Color(0xff75729e),
115116
fontWeight: FontWeight.bold,
@@ -121,6 +122,7 @@ class _LineChart extends StatelessWidget {
121122
showTitles: true,
122123
reservedSize: 22,
123124
margin: 10,
125+
interval: 1,
124126
getTextStyles: (context, value) => const TextStyle(
125127
color: Color(0xff72719b),
126128
fontWeight: FontWeight.bold,

example/lib/line_chart/samples/line_chart_sample10.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class _LineChartSample10State extends State<LineChartSample10> {
8484
clipData: FlClipData.all(),
8585
gridData: FlGridData(
8686
show: true,
87+
drawVerticalLine: false,
8788
),
8889
lineBarsData: [
8990
sinLine(sinPoints),

0 commit comments

Comments
 (0)