'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)
Solution 1:[1]
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);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | salihgueler |
