diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 03d0679a85..867cac2a6e 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -606,7 +606,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter { ..strokeCap = strokeCap ?? StrokeCap.round ..style = PaintingStyle.stroke; // If hasGap is true, draw the background arc with a gap. - if (hasGap && value! > _epsilon) { + if (hasGap && value != null && value! > _epsilon) { final double arcRadius = arcActualSize.shortestSide / 2; final double strokeRadius = strokeWidth / arcRadius; final double gapRadius = trackGap! / arcRadius; diff --git a/packages/flutter/test/material/progress_indicator_theme_test.dart b/packages/flutter/test/material/progress_indicator_theme_test.dart index bc2b7fdd40..00bc55cca7 100644 --- a/packages/flutter/test/material/progress_indicator_theme_test.dart +++ b/packages/flutter/test/material/progress_indicator_theme_test.dart @@ -376,6 +376,25 @@ void main() { ); }); + testWidgets( + 'CircularProgressIndicator.year2023 set to false and provided circularTrackColor does not throw exception', + (WidgetTester tester) async { + const Color circularTrackColor = Color(0XFF0000FF); + final ThemeData theme = ThemeData( + progressIndicatorTheme: const ProgressIndicatorThemeData( + circularTrackColor: circularTrackColor, + year2023: false, + ), + ); + + await tester.pumpWidget( + Theme(data: theme, child: const Center(child: CircularProgressIndicator())), + ); + + expect(tester.takeException(), null); + }, + ); + testWidgets( 'Opt into 2024 CircularProgressIndicator appearance with ProgressIndicatorThemeData.year2023', (WidgetTester tester) async {