improved app rating UI logic by showing a disabled state during availability check instead of hiding the component
This commit is contained in:
@@ -49,23 +49,13 @@ class _OverhangState extends State<Overhang> {
|
||||
FutureBuilder(
|
||||
future: InAppReview.instance.isAvailable(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return const SizedBox.shrink();
|
||||
|
||||
String? getPlatformStoreName() {
|
||||
if (Platform.isAndroid) return 'Play store';
|
||||
if (Platform.isIOS) return 'App store';
|
||||
return null;
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.star_rate_outlined)),
|
||||
title: const Text('App bewerten'),
|
||||
subtitle: getPlatformStoreName().wrapNullable(
|
||||
(data) => Text('Im $data'),
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: () {
|
||||
InAppReview.instance
|
||||
Future<void> rate() => InAppReview.instance
|
||||
.openStoreListing(appStoreId: '6458789560')
|
||||
.then(
|
||||
(value) {
|
||||
@@ -82,7 +72,17 @@ class _OverhangState extends State<Overhang> {
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
final ready = snapshot.connectionState == ConnectionState.done;
|
||||
return ListTile(
|
||||
enabled: ready,
|
||||
leading: const CenteredLeading(Icon(Icons.star_rate_outlined)),
|
||||
title: const Text('App bewerten'),
|
||||
subtitle: getPlatformStoreName().wrapNullable(
|
||||
(data) => Text('Im $data'),
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: !ready ? null : rate
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user