小编sha*_*kky的帖子

如何获取Android设备版本-Flutter

我一直在尝试获取Android设备版本(例如11、12)。我一直在尝试只获取数字

这就是我到目前为止所做的

  void checkVersion(){
    print(Platform.operatingSystemVersion); // it prints "sdk_gphone64_arm64-userdebug 12 S2B2.211203.006 8015633 dev-keys"

   // I'm able to fetch the version number by splitting the string 
   // but the problem is that format of above string will vary by
   // operating system, so not suitable for parsing 

   int platformVersion = int.parse(Platform.operatingSystemVersion.split(' ')[1]); it prints '12'
  }
Run Code Online (Sandbox Code Playgroud)

dart flutter

2
推荐指数
1
解决办法
3688
查看次数

标签 统计

dart ×1

flutter ×1