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