You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here a null check is required on items before calling items!.addAll.
Following is the method from base class which this code calls (super.buildLegendItems) and it can return null.
On which target platforms have you observed this bug?
Web
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):[✓] Flutter (Channel stable, 3.24.1, on macOS 14.3.1 23D60 darwin-arm64, locale en-IN)[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/to/macos-android-setup for more details.[✓] Xcode - develop for iOS and macOS (Xcode 15.3)[✓] Chrome - develop for the web[✓] Android Studio (version 2023.2)[✓] VS Code (version 1.86.2)[✓] Connected device (3 available)[✓] Network resources! Doctor found issues in 1 category.
The text was updated successfully, but these errors were encountered:
PT10
changed the title
Line chart with one series throws exception
Null check missing in code: Line chart with hidden labels throws exception
Dec 17, 2024
Bug description
There is a clear issue in the code. When "isVisibleInLegend" is false, null is returned. And then there is no null check in the caller.
chart_series.dart
Here a null check is required on items before calling items!.addAll.
Following is the method from base class which this code calls (super.buildLegendItems) and it can return null.
Steps to reproduce
Any line chart which a single series and show legend flag on.
Code sample
Code sample
@OverRide
List? buildLegendItems(int index) {
final List? items = super.buildLegendItems(index);
if (trendlineContainer != null) {
items!.addAll(trendlineContainer!.buildLegendItems(index, this)!);
}
return items;
}
@OverRide
List? buildLegendItems(int index) {
if (isVisibleInLegend) {
final LegendItem legendItem = ChartLegendItem(
text: legendItemText ?? name,
iconType: toLegendShapeMarkerType(legendIconType, this),
iconColor: legendIconColor(),
iconBorderColor: legendIconBorderColor(),
iconBorderWidth: legendIconBorderWidth(),
series: this,
seriesIndex: index,
pointIndex: 0,
isToggled: _isToggled(),
shader: legendIconShader(),
overlayMarkerType: markerSettings.isVisible
? toShapeMarkerType(markerSettings.shape)
: null,
imageProvider: legendIconType == LegendIconType.image
? parent?.legend?.image
: null,
onTap: handleLegendItemTapped,
onRender: _handleLegendItemCreated,
);
return [legendItem];
} else {
return null;
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Stack Traces
Stack Traces
On which target platforms have you observed this bug?
Web
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: