flutter/lib/utils/getCommonDictionary.dart

26 lines
608 B
Dart
Raw Normal View History

library;
import 'package:loopin/api/common_api.dart';
import 'package:loopin/service/http.dart';
class Commondictionary {
// 获取字段配置
static Future<List<dynamic>> getCommonDictionary(String key) async {
try {
final res = await Http.get('${CommonApi.dictionaryApi}$key');
if (res['code'] == 200 && res['data'] != null) {
final data = res['data'];
if (data is List) {
return data;
} else {
return [];
}
}
return [];
} catch (e) {
print('获取字典数据失败: $e');
return [];
}
}
}