【发布时间】:2020-10-30 05:05:46
【问题描述】:
嗨
我在颤振中遇到错误
它只是从提供者那里获取加载状态我在我使用的所有提供者中都有相同的错误
getter 'loadingStatus' 在 null Flutter 上被调用
此错误仅出现在控制台中,但应用运行正常 -_-
class _DoctorInfoPageState extends State<DoctorInfoPage> {
GeneralService _generalService;
ProfileService _profileService;
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
_generalService = Provider.of<GeneralService>(context);
_profileService = Provider.of<ProfileService>(context);
loadingReviews();
});
}
loadingReviews() async {
_generalService.setLoadingState(true);
await _profileService.getReviews(context);
_generalService.setLoadingState(false);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0.0,
centerTitle: true,
backgroundColor: Colors.white,
leading: IconButton(
icon:
Icon(Icons.chevron_left, size: 30, color: Const.appMainBlueColor),
onPressed: () {
print('test');
},
),
title: Text(
"Doctor Info",
style: TextStyle(
color: Const.appMainBlueColor,
fontWeight: FontWeight.w600,
fontSize: 18),
),
),
body: _generalService.loadingStatus != null &&
_generalService.loadingStatus
? Center(child: PumpHeart(size: 35.0))
: SafeArea()
);
}
}
我尝试了越来越多,但没有任何改变,所以蚂蚁可以告诉我错误在哪里吗?
这是供应商代码
class GeneralService with ChangeNotifier {
bool _isLoading = false;
// Change Loading Status
void setLoadingState(bool value) {
_isLoading = value;
notifyListeners();
}
// Get Loading Status
bool get loadingStatus => _isLoading;
}
【问题讨论】:
标签: flutter dart dart-pub flutter-test