cake_wallet/lib/utils/distribution_info.dart
Omar Hatem 62007975e1
Old state (#999)
* Fix Bitcoin transactions not showing (#978)

* handle multiple responses coming in a single event

* Add timeout for getting transaction info, to allow other transactions to be returned in case of any failure or network issue

* Handle other cases of receiving multiple messages in the same response

* Fix shib and storj (#997)

* Merge main branch

* Add missing files

---------

Co-authored-by: Justin Ehrenhofer <justin.ehrenhofer@gmail.com>
2023-07-14 01:48:47 +03:00

39 lines
1 KiB
Dart

import 'dart:io';
import 'package:package_info_plus/package_info_plus.dart';
enum DistributionType { googleplay, github, appstore, fdroid }
class DistributionInfo {
DistributionInfo._();
static DistributionInfo get instance => DistributionInfo._();
Future<String> getDistributionPath() async {
final isPlayStore = await isInstalledFromPlayStore();
final distributionPath = _getDistributionPath(isPlayStore);
return distributionPath.name;
}
DistributionType _getDistributionPath(bool isPlayStore) {
if (isPlayStore) {
return DistributionType.googleplay;
} else if (Platform.isAndroid) {
return DistributionType.github;
} else if (Platform.isIOS) {
return DistributionType.appstore;
} else {
return DistributionType.github;
}
}
Future<bool> isInstalledFromPlayStore() async {
try {
final packageInfo = await PackageInfo.fromPlatform();
return packageInfo.packageName == 'com.android.vending';
} catch (e) {
print('Error: $e');
return false;
}
}
}