当前位置:网站首页>flutter provide
flutter provide
2022-07-15 23:42:00 【氤氲息】
首先是写一个model
import 'package:flutter/widgets.dart';
import 'package:social_im/models/activity/FlipCardsSettingBean.dart';
import 'package:social_im/models/activity/slideSettingBean.dart';
import '../pages/shakeGame/data/GetUserSetting.dart';
class SlideMatchModel with ChangeNotifier {
SlideSettingBean? _slideSettingBean;
get slideSettingBean => _slideSettingBean;
setSlideSettingBean(SlideSettingBean slideSettingBean) {
_slideSettingBean = slideSettingBean;
notifyListeners();
return _slideSettingBean;
}
FlipCardsSettingBean? _flipCardsSettingBean;
get flipCardsSettingBean => _flipCardsSettingBean;
setFlipCardsSettingBean(FlipCardsSettingBean flipCardsSettingBean) {
_flipCardsSettingBean = flipCardsSettingBean;
notifyListeners();
return _flipCardsSettingBean;
}
GetUserSetting? _getUserSetting;
get getUserSetting => _getUserSetting;
setGetUserSetting(GetUserSetting getUserSetting) {
_getUserSetting = getUserSetting;
notifyListeners();
return _getUserSetting;
}
clear() {
_slideSettingBean = null;
_flipCardsSettingBean = null;
_getUserSetting = null;
notifyListeners();
}
}
然后设置数据
//获取摇一摇活动次数
void getShakeTime() {
EasyLoading.show();
HttpRequest.intance.postHttpFromBusiness(Api.API_SHAKE_SETTING, (data) {
setState(() {
//网络没问题
_connectError=false;
});
if (EasyLoading.isShow) {
EasyLoading.dismiss();
}
GetUserSetting getUserSetting = GetUserSetting.fromJson(data);
Provider.of<SlideMatchModel>(Global.appContext, listen: false)
.setGetUserSetting(getUserSetting);
//获取摇一摇次数
if (mounted) {
setState(() {
_shakeTime = getUserSetting.remainTimes!.remainShakeTimes;
});
}
}, (error) {
});
}
最后在任何地方使用
GetUserSetting? getUserSetting;
getUserSetting =
Provider.of<SlideMatchModel>(context, listen: true).getUserSetting;
边栏推荐
- Design of pattern water lamp based on 51 single chip microcomputer
- Redis concept, configuration and sentinel high availability of redis
- 论文阅读 A Data-Driven Graph Generative Model for Temporal Interaction Networks
- Wireshark packet capturing debugging (three-way handshake, four-way disconnection)
- Valgrind
- Filter
- 伦敦银行情走势怎样产生
- 深圳开展建设工程合同网签试点,法大大助力建筑数字化
- (manual) [sqli labs44, 45] post character injection, blind injection, Stack Injection
- 解密静态路由,一文分析静态路由优缺点!
猜你喜欢

没有sudo权限的情况下,如何在Ubuntu安装sqlite

4 * 4 * 4 Light Cube production and sharing

EMQX 服务器建立SSL/TLS安全连接、单向、双向

Filter

JVM简述 GC垃圾回收机制

Quweihai: insisting on choosing and not giving up is the magic weapon to realize the original intention

ping报文与ICMP报文头

Flink (VI) fault tolerance mechanism

【漫步刷题路】- 逆序字符串II

Redis concept, configuration and sentinel high availability of redis
随机推荐
[JVM] garbage collector
Summary of process synchronization problems
Emqx server establishes ssl/tls secure connection, one-way and two-way
JVM briefly introduces GC garbage collection mechanism
Breathing lamp circuit based on 555 timer
低代码渲染那些事
Two bytes, carried out by the interviewer and shared with everyone
openpcdet之pointpillar代码阅读——第二篇:网络结构
Context object instance
喜事乐,一场蓄谋已久的购物新时代
Low code rendering
Shenzhen has launched a pilot project of online signing of construction contracts, and France has greatly contributed to building digitalization
【开发教程6】疯壳·开源蓝牙智能健康手表-触摸
Power system unit commitment (realized by matlab code)
Experiment 4 image restoration and geometric correction
【sql面试题】求连续点击三次的用户数,而且中间不能有别人的点击
解密静态路由,一文分析静态路由优缺点!
干货解析 | 公有云时代,如何上好云、管好云?点击报名,解答全部疑问!
SQLyog无操作一段时间后重新操作会卡死问题(解决办法)
JS array object in goods_ With the same ID and an object, put goods_ size_ Add ID values together