How to switch loading indicator as default base on device ( Andriod show circularprogressindicator and IOS show CupertinoActivityIndicator)
How to switch loading indicator as default base on device ( Andriod show circularprogressindicator and IOS show CupertinoActivityIndicator)
You can do that by creating your own widget. Flutter does it for BackButtonIcon widget.
I just got the code from it and modifying it for you to use :) All you need to do is to use LoadingIndicator() where you need it.
class LoadingIndicator extends StatelessWidget {
const LoadingIndicator({Key? key}) : super(key: key);
/// Returns the appropriate "loading indicator" icon for the given `platform`.
Widget _getIndicatorWidget(TargetPlatform platform) {
switch (platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return const CupertinoActivityIndicator();
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
default:
return const CircularProgressIndicator();
}
}
@override
Widget build(BuildContext context) =>
_getIndicatorWidget(Theme.of(context).platform);
}