openStore static method
Future<PlayxVersionUpdateResult<bool> >
openStore({
- required String storeUrl,
- LaunchMode launchMode = LaunchMode.externalApplication,
Open the Google play store in Android Or App Store in IOS
Takes String storeUrl : which is the URL to the Specified store.
LaunchMode
:Which decide the desired mode to launch the store.
Support for these modes varies by platform. Platforms that do not support
the requested mode may substitute another mode. See launchUrl
for more details.
returns PlayxVersionUpdateResult with bool on success.
and returns PlayxVersionUpdateError on error which contains information about the error.
Implementation
static Future<PlayxVersionUpdateResult<bool>> openStore(
{required String storeUrl,
LaunchMode launchMode = LaunchMode.externalApplication}) async {
final Uri url = Uri.parse(storeUrl);
if (await canLaunchUrl(url)) {
try {
final isLaunched = await launchUrl(url, mode: launchMode);
return PlayxVersionUpdateResult.success(isLaunched);
} catch (e) {
return PlayxVersionUpdateResult.error(DefaultFailureError(
errorMsg: 'Could not launch store. : ${e.toString()}'));
}
} else {
return const PlayxVersionUpdateResult.error(
DefaultFailureError(errorMsg: 'Could not launch store.'));
}
}