App crashing in release for Bar chart graphs after upgrading to flutter 2.8.1
- Dominant language
- Dart
- Stars
- 7.6k
- Forks
- 2k
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 2
Description
Our app uses fl_chart for drawing line and bar graphs, the app was working fine for the code that we have written for displaying bar graphs on the flutter prior to version 2.8 but after upgrading to version 2.8.0 then 2.8.1 app is crashing when we try to visit pages where we are displaying the bar graphs. This only happens in a release build and the app works fine in debug mode. We have firebase crashlytics in place but nothing is showing in the logs this is only happening in the release build and also there are no logs reported when I try to run the app in release mode with debug true in the android studio at app crash.
Below is the code snippet for the bar graph
```dart
Container(
padding: const EdgeInsets.only(top: 15),
margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 25),
height: width * 0.8,
width: width,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
borderData: FlBorderData(
show: minY >= 0 ? true : false,
border: const Border(
bottom: BorderSide(
color: Color.fromRGBO(238, 238, 238, 1),
),
),
),
titlesData: FlTitlesData(
leftTitles: SideTitles(showTitles: false),
rightTitles: SideTitles(showTitles: false),
topTitles: SideTitles(showTitles: false),
bottomTitles: SideTitles(
showTitles: true,
margin: 15,
getTitles: (double id) => xaxis
.firstWhere((data) => data.index - 1 == id.toInt())
.year,
getTextStyles: (context, value) => const TextStyle(
fontSize: 12,
color: inputTextColor,
),
),
),
gridData: FlGridData(
drawVerticalLine: false,
drawHorizontalLine: minY < 0 ? true : false,
checkToShowHorizontalLine: (value) => value == 0,
getDrawingHorizontalLine: (value) {
return FlLine(
color: const Color.fromRGBO(238, 238, 238, 1),
);
},
),
barTouchData: BarTouchData(
enabled: true,
touchTooltipData: BarTouchTooltipData(
tooltipBgColor: primaryColor,
tooltipRoundedRadius: 2,
tooltipPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
fitInsideHorizontally: true,
fitInsideVertically: true,
getTooltipItem: (group, groupIndex, rod, rodIndex) {
String date = xaxis[groupIndex].year;
String pre = rodIndex == 0 ? "Sales" : "Profit";
return BarTooltipItem(
"${(rod.y).toStringAsFixed(2)} Cr. - $pre\n",
TextStyle(
fontSize: 10,
color: rodIndex == 0
? inputTextColor
: rod.y > 0
? secondaryColor
: colorDanger,
),
children: [
TextSpan(
text: date,
style: TextStyle(
fontSize: 10,
color: inputTextColor.withOpacity(0.7)),
),
],
);
},
),
),
barGroups: xaxis
.map(
(data) => BarChartGroupData(
x: data.index - 1,
barRods: [
BarChartRodData(
y: rsalesNumbers[data.index - 1],
width: 18,
borderRadius: BorderRadius.zero,
colors: [inputTextColor],
),
BarChartRodData(
y: rprofitNumbers[data.index - 1],
width: 18,
borderRadius: BorderRadius.zero,
colors: [secondaryColor],
)
],
barsSpace: 0,
),
)
.toList(),
),
),
),
```
**Versions**
- Flutter version `2.8.1`
- Flchart version `^0.40.6`
`flutter doctor -v`
```
Flutter (Channel stable, 2.8.1, on macOS 11.5.2 20G95 darwin-x64, locale en-IN)
• Flutter version 2.8.1 at /Users/snghnishant/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (6 days ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/snghnishant/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.63.1)
• VS Code at /Users/snghnishant/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.29.0
[✓] Connected device (2 available)
• SM G920I (mobile) • 1115fb709c272f03 • android-arm64 • Android 7.0 (API 24)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
• No issues found!
```
Contributor guide
Research direction
Start with the provided BarChart snippet and reproduce the crash in a release build using Flutter 2.8.1 and fl_chart 0.40.6. Compare release and debug behavior and inspect available crash output, since the report provides no failure trace. Done means identifying the release-only cause and confirming that the bar graph no longer crashes in a release build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100