I'm currently working on a Flutter project and trying to incorporate Theming into my app. Specifically, I want to apply Theming to the CircularProgressIndicator.adaptive() widget. While I've successfully changed the color on Android using the regular CircularProgressIndicator, it seems that the adaptive version only responds to color changes on Android.
Nothing in the documentation is pointing me to a way to give the progress indicator a color using Theming. Is this a known limitation or possibly a bug in Flutter? I'm wondering if I'm missing something fundamental about Theming in Flutter.
Has anyone else encountered this issue, and is there a recommended workaround? I'd appreciate any insights or guidance on how to achieve consistent Theming for CircularProgressIndicator.adaptive() across both Android and iOS platforms.
Thank you!
I prepared a minimal example:
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
final myThemeData = ThemeData(
progressIndicatorTheme: const ProgressIndicatorThemeData(
color: Colors.red,
),
);
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Theme(
data: myThemeData.copyWith(platform: TargetPlatform.iOS),
child: const CircularProgressIndicator.adaptive()),
const SizedBox(height: 50),
Theme(
data: myThemeData.copyWith(platform: TargetPlatform.android),
child: const CircularProgressIndicator.adaptive()),
],
),
),
),
);
}
}
Which produces the following result:
I want both of the indicators to have a red color.
To achieve this just do
Setting the theme parameter in your MaterialApp gives it an app-wide theme, so now your progress indicator would always be red or whatever color you set to it.