Mostrar la versión en la app

This commit is contained in:
2026-05-05 22:56:25 +02:00
parent 031c190d74
commit 08235999d3
3 changed files with 84 additions and 4 deletions
+29
View File
@@ -0,0 +1,29 @@
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';
}
}