12345678910111213141516171819 |
- import 'package:flutter/foundation.dart';
- import 'package:flutter/services.dart';
- class NativeVersionChannel {
- //初始化MethodChannel对象
- static const MethodChannel _channel = MethodChannel('com.room/opapp');
- /// 获取 原生系统 版本号 如安卓的11
- static Future<int> getAndroidSdkInt() async {
- if (defaultTargetPlatform != TargetPlatform.android) return 0; // 非Android设备返回0
- try {
- final version = await _channel.invokeMethod<int>('getAndroidSdkInt');
- return version ?? 0;
- } on PlatformException catch (e) {
- print("获取 Android 版本失败: ${e.message}");
- return 0;
- }
- }
- }
|