import 'package:zhiying_comm/util/net_util.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class BaseSettingModel { String fileProvider; String fileBucketHost; String fileBucketHostProtocol; Map tab; static BaseSettingModel _setting; static BaseSettingModel get setting { if (_setting == null) { Logger.error('暂未初始化'); } return _setting; } BaseSettingModel( {this.fileProvider, this.fileBucketHost, this.fileBucketHostProtocol}); BaseSettingModel.fromJson(Map json) { fileProvider = json['file_provider']; fileBucketHost = json['file_bucket_host']; fileBucketHostProtocol = json['file_bucket_host_protocol']; tab = Map.from(json['bottom_nav']); } Map toJson() { final Map data = new Map(); data['file_provider'] = this.fileProvider; data['file_bucket_host'] = this.fileBucketHost; data['file_bucket_host_protocol'] = this.fileBucketHostProtocol; data['bottom_nav'] = this.tab; return data; } static Future init() async { Map result = await NetUtil.post('/api/v1/new/config.json', method: NetMethod.GET); try { var data = result['data']; _setting = BaseSettingModel.fromJson(Map.from(data)); Logger.debug('基础设置初始化'); return _setting; } catch (err) { Logger.error(err); } return null; } }