30 lines
757 B
Dart
30 lines
757 B
Dart
import 'package:flutter/services.dart';
|
|
|
|
class ServicioVersionApp {
|
|
static const _channel = MethodChannel('farolero/app_info');
|
|
|
|
static Future<String> obtenerVersion() async {
|
|
final Map<String, dynamic>? info;
|
|
try {
|
|
info = await _channel.invokeMapMethod<String, dynamic>(
|
|
'getAppVersion',
|
|
);
|
|
} on PlatformException {
|
|
return '-';
|
|
} on MissingPluginException {
|
|
return '-';
|
|
}
|
|
|
|
final versionName = info?['versionName']?.toString();
|
|
final versionCode = info?['versionCode']?.toString();
|
|
|
|
if (versionName == null || versionName.isEmpty) {
|
|
return '-';
|
|
}
|
|
if (versionCode == null || versionCode.isEmpty) {
|
|
return versionName;
|
|
}
|
|
return '$versionName+$versionCode';
|
|
}
|
|
}
|