Skip to content

Commit

Permalink
refactor: Put constructors to const
Browse files Browse the repository at this point in the history
  • Loading branch information
lsaudon authored and imaNNeo committed May 6, 2023
1 parent 4da5af6 commit 944f988
Show file tree
Hide file tree
Showing 44 changed files with 635 additions and 1,008 deletions.
16 changes: 8 additions & 8 deletions example/lib/presentation/samples/bar/bar_chart_sample1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ class BarChartSample1State extends State<BarChartSample1> {
),
titlesData: FlTitlesData(
show: true,
rightTitles: AxisTitles(
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: AxisTitles(
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
bottomTitles: AxisTitles(
Expand All @@ -239,7 +239,7 @@ class BarChartSample1State extends State<BarChartSample1> {
reservedSize: 38,
),
),
leftTitles: AxisTitles(
leftTitles: const AxisTitles(
sideTitles: SideTitles(
showTitles: false,
),
Expand All @@ -249,7 +249,7 @@ class BarChartSample1State extends State<BarChartSample1> {
show: false,
),
barGroups: showingGroups(),
gridData: FlGridData(show: false),
gridData: const FlGridData(show: false),
);
}

Expand Down Expand Up @@ -307,17 +307,17 @@ class BarChartSample1State extends State<BarChartSample1> {
reservedSize: 38,
),
),
leftTitles: AxisTitles(
leftTitles: const AxisTitles(
sideTitles: SideTitles(
showTitles: false,
),
),
topTitles: AxisTitles(
topTitles: const AxisTitles(
sideTitles: SideTitles(
showTitles: false,
),
),
rightTitles: AxisTitles(
rightTitles: const AxisTitles(
sideTitles: SideTitles(
showTitles: false,
),
Expand Down Expand Up @@ -381,7 +381,7 @@ class BarChartSample1State extends State<BarChartSample1> {
return throw Error();
}
}),
gridData: FlGridData(show: false),
gridData: const FlGridData(show: false),
);
}

Expand Down
6 changes: 3 additions & 3 deletions example/lib/presentation/samples/bar/bar_chart_sample2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ class BarChartSample2State extends State<BarChartSample2> {
),
titlesData: FlTitlesData(
show: true,
rightTitles: AxisTitles(
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: AxisTitles(
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
bottomTitles: AxisTitles(
Expand All @@ -158,7 +158,7 @@ class BarChartSample2State extends State<BarChartSample2> {
show: false,
),
barGroups: showingBarGroups,
gridData: FlGridData(show: false),
gridData: const FlGridData(show: false),
),
),
),
Expand Down
8 changes: 4 additions & 4 deletions example/lib/presentation/samples/bar/bar_chart_sample3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class _BarChart extends StatelessWidget {
titlesData: titlesData,
borderData: borderData,
barGroups: barGroups,
gridData: FlGridData(show: false),
gridData: const FlGridData(show: false),
alignment: BarChartAlignment.spaceAround,
maxY: 20,
),
Expand Down Expand Up @@ -93,13 +93,13 @@ class _BarChart extends StatelessWidget {
getTitlesWidget: getTitles,
),
),
leftTitles: AxisTitles(
leftTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: AxisTitles(
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
rightTitles: AxisTitles(
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
);
Expand Down
4 changes: 2 additions & 2 deletions example/lib/presentation/samples/bar/bar_chart_sample4.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class BarChartSample4State extends State<BarChartSample4> {
getTitlesWidget: leftTitles,
),
),
topTitles: AxisTitles(
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
rightTitles: AxisTitles(
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
),
Expand Down
8 changes: 4 additions & 4 deletions example/lib/presentation/samples/bar/bar_chart_sample6.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ class BarChartSample6 extends StatelessWidget {
BarChartData(
alignment: BarChartAlignment.spaceBetween,
titlesData: FlTitlesData(
leftTitles: AxisTitles(),
rightTitles: AxisTitles(),
topTitles: AxisTitles(),
leftTitles: const AxisTitles(),
rightTitles: const AxisTitles(),
topTitles: const AxisTitles(),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
Expand All @@ -136,7 +136,7 @@ class BarChartSample6 extends StatelessWidget {
),
barTouchData: BarTouchData(enabled: false),
borderData: FlBorderData(show: false),
gridData: FlGridData(show: false),
gridData: const FlGridData(show: false),
barGroups: [
generateGroupData(0, 2, 3, 2),
generateGroupData(1, 2, 5, 1.7),
Expand Down
6 changes: 3 additions & 3 deletions example/lib/presentation/samples/bar/bar_chart_sample7.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _BarChartSample7State extends State<BarChartSample7> {
titlesData: FlTitlesData(
show: true,
leftTitles: AxisTitles(
drawBehindEverything: true,
drawBelowEverything: true,
sideTitles: SideTitles(
showTitles: true,
reservedSize: 30,
Expand Down Expand Up @@ -96,8 +96,8 @@ class _BarChartSample7State extends State<BarChartSample7> {
},
),
),
rightTitles: AxisTitles(),
topTitles: AxisTitles(),
rightTitles: const AxisTitles(),
topTitles: const AxisTitles(),
),
gridData: FlGridData(
show: true,
Expand Down
26 changes: 13 additions & 13 deletions example/lib/presentation/samples/line/line_chart_sample1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class _LineChart extends StatelessWidget {
Widget build(BuildContext context) {
return LineChart(
isShowingMainData ? sampleData1 : sampleData2,
swapAnimationDuration: const Duration(milliseconds: 250),
duration: const Duration(milliseconds: 250),
);
}

Expand Down Expand Up @@ -50,10 +50,10 @@ class _LineChart extends StatelessWidget {
bottomTitles: AxisTitles(
sideTitles: bottomTitles,
),
rightTitles: AxisTitles(
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: AxisTitles(
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
leftTitles: AxisTitles(
Expand All @@ -67,18 +67,18 @@ class _LineChart extends StatelessWidget {
lineChartBarData1_3,
];

LineTouchData get lineTouchData2 => LineTouchData(
LineTouchData get lineTouchData2 => const LineTouchData(
enabled: false,
);

FlTitlesData get titlesData2 => FlTitlesData(
bottomTitles: AxisTitles(
sideTitles: bottomTitles,
),
rightTitles: AxisTitles(
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: AxisTitles(
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
leftTitles: AxisTitles(
Expand Down Expand Up @@ -163,7 +163,7 @@ class _LineChart extends StatelessWidget {
getTitlesWidget: bottomTitleWidgets,
);

FlGridData get gridData => FlGridData(show: false);
FlGridData get gridData => const FlGridData(show: false);

FlBorderData get borderData => FlBorderData(
show: true,
Expand All @@ -181,7 +181,7 @@ class _LineChart extends StatelessWidget {
color: AppColors.contentColorGreen,
barWidth: 8,
isStrokeCapRound: true,
dotData: FlDotData(show: false),
dotData: const FlDotData(show: false),
belowBarData: BarAreaData(show: false),
spots: const [
FlSpot(1, 1),
Expand All @@ -199,7 +199,7 @@ class _LineChart extends StatelessWidget {
color: AppColors.contentColorPink,
barWidth: 8,
isStrokeCapRound: true,
dotData: FlDotData(show: false),
dotData: const FlDotData(show: false),
belowBarData: BarAreaData(
show: false,
color: AppColors.contentColorPink.withOpacity(0),
Expand All @@ -219,7 +219,7 @@ class _LineChart extends StatelessWidget {
color: AppColors.contentColorCyan,
barWidth: 8,
isStrokeCapRound: true,
dotData: FlDotData(show: false),
dotData: const FlDotData(show: false),
belowBarData: BarAreaData(show: false),
spots: const [
FlSpot(1, 2.8),
Expand All @@ -236,7 +236,7 @@ class _LineChart extends StatelessWidget {
color: AppColors.contentColorGreen.withOpacity(0.5),
barWidth: 4,
isStrokeCapRound: true,
dotData: FlDotData(show: false),
dotData: const FlDotData(show: false),
belowBarData: BarAreaData(show: false),
spots: const [
FlSpot(1, 1),
Expand All @@ -254,7 +254,7 @@ class _LineChart extends StatelessWidget {
color: AppColors.contentColorPink.withOpacity(0.5),
barWidth: 4,
isStrokeCapRound: true,
dotData: FlDotData(show: false),
dotData: const FlDotData(show: false),
belowBarData: BarAreaData(
show: true,
color: AppColors.contentColorPink.withOpacity(0.2),
Expand All @@ -275,7 +275,7 @@ class _LineChart extends StatelessWidget {
color: AppColors.contentColorCyan.withOpacity(0.5),
barWidth: 2,
isStrokeCapRound: true,
dotData: FlDotData(show: true),
dotData: const FlDotData(show: true),
belowBarData: BarAreaData(show: false),
spots: const [
FlSpot(1, 3.8),
Expand Down
12 changes: 6 additions & 6 deletions example/lib/presentation/samples/line/line_chart_sample10.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class _LineChartSample10State extends State<LineChartSample10> {
maxY: 1,
minX: sinPoints.first.x,
maxX: sinPoints.last.x,
lineTouchData: LineTouchData(enabled: false),
clipData: FlClipData.all(),
gridData: FlGridData(
lineTouchData: const LineTouchData(enabled: false),
clipData: const FlClipData.all(),
gridData: const FlGridData(
show: true,
drawVerticalLine: false,
),
Expand All @@ -96,7 +96,7 @@ class _LineChartSample10State extends State<LineChartSample10> {
sinLine(sinPoints),
cosLine(cosPoints),
],
titlesData: FlTitlesData(
titlesData: const FlTitlesData(
show: false,
),
),
Expand All @@ -111,7 +111,7 @@ class _LineChartSample10State extends State<LineChartSample10> {
LineChartBarData sinLine(List<FlSpot> points) {
return LineChartBarData(
spots: points,
dotData: FlDotData(
dotData: const FlDotData(
show: false,
),
gradient: LinearGradient(
Expand All @@ -126,7 +126,7 @@ class _LineChartSample10State extends State<LineChartSample10> {
LineChartBarData cosLine(List<FlSpot> points) {
return LineChartBarData(
spots: points,
dotData: FlDotData(
dotData: const FlDotData(
show: false,
),
gradient: LinearGradient(
Expand Down
10 changes: 5 additions & 5 deletions example/lib/presentation/samples/line/line_chart_sample11.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ class _Chart extends StatelessWidget {

FlLine getHorizontalVerticalLine(double value) {
if ((value - baselineY).abs() <= 0.1) {
return FlLine(
return const FlLine(
color: Colors.white70,
strokeWidth: 1,
dashArray: [8, 4],
);
} else {
return FlLine(
return const FlLine(
color: Colors.blueGrey,
strokeWidth: 0.4,
dashArray: [8, 4],
Expand All @@ -131,13 +131,13 @@ class _Chart extends StatelessWidget {

FlLine getVerticalVerticalLine(double value) {
if ((value - baselineX).abs() <= 0.1) {
return FlLine(
return const FlLine(
color: Colors.white70,
strokeWidth: 1,
dashArray: [8, 4],
);
} else {
return FlLine(
return const FlLine(
color: Colors.blueGrey,
strokeWidth: 0.4,
dashArray: [8, 4],
Expand Down Expand Up @@ -196,7 +196,7 @@ class _Chart extends StatelessWidget {
maxX: 10,
baselineX: baselineX,
),
swapAnimationDuration: Duration.zero,
duration: Duration.zero,
);
}
}
Loading

0 comments on commit 944f988

Please sign in to comment.