适配新版本api

This commit is contained in:
jyuesong
2022-04-24 12:12:53 +08:00
parent 6c3c15a85d
commit 70f4df431f
7 changed files with 144 additions and 25 deletions

View File

@@ -1,7 +1,40 @@
import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';
import '../module/home/system_bean.dart';
class Utils {
static final SystemBean systemBean = SystemBean();
static bool isUpperVersion() {
try {
List<String>? version = Utils.systemBean.version?.split("\.");
String f = version?[0] ?? "2";
String s = version?[1] ?? "10";
String t = version?[2] ?? "0";
int first = int.parse(f);
int second = int.parse(s);
int third = int.parse(t);
/// 2.10.13 及以下版本
if (first > 2) {
return true;
}
if (second > 10) {
return true;
}
if (third > 13) {
return true;
}
return false;
} catch (e) {
return false;
}
}
static void hideKeyBoard(BuildContext context) {
FocusScope.of(context).requestFocus(FocusNode());
}
@@ -71,7 +104,7 @@ class Utils {
}
static String formatMessageTime(int time) {
if(time == 0){
if (time == 0) {
return "-";
}
DateTime current = DateTime.now();