问题描述
我有一个用于过滤产品的抽屉,我的抽屉是从另一个这样的飞镖文件导入的。
这是homePage.dart's
支架。导入的抽屉如下:
return Scaffold(
key: _scaffoldkey,appBar:AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back,color: Colors.black),onpressed: () => Navigator.pop(context)),backgroundColor: Colors.white,title: Text('HomePage',style: TextStyle(color: Colors.black),textAlign: TextAlign.left),),endDrawer:filterDrawer(context),
这是filterDrawer.dart
文件。
Container filterDrawer(context) {
TextStyle childStyle = TextStyle(fontSize: 14);
TextStyle childActiveStyle = TextStyle(fontSize: 14,color: primaryColor);
var _supRepo = Provider.of<supplierRepo>(context,listen: false);
return Container(
color: Colors.white,width: MediaQuery.of(context).size.width * 0.75,child: Column(
children: [Expanded(
child: ListView.builder(
itemCount: _supRepo.storeFilterList.length,itemBuilder: (context,index) {
return _supRepo.storeFilterList[index]['options'].length == 0
? SizedBox(
height: 0.1,)
: ExpansionTile(
title: Text(_supRepo.storeFilterList[index]['name']),childrenPadding: EdgeInsets.only(left: 10),children: List<Widget>.generate(
_supRepo.storeFilterList[index]['options'].length,(subIndex) {
return ListTile(
onTap:() {
_supRepo.setFilterData(
_supRepo.storeFilterList[index]
['filterQueryName']
.toString(),_supRepo.storeFilterList[index]['options']
[subIndex]['id']);
},trailing: Icon(Icons.check_circle_outline),title: Text(_supRepo.storeFilterList[index]['options'][subIndex]['name'],style: _supRepo.filterQueryList[_supRepo.storeFilterList[index]['filterQueryName'].toString()] != null
? (_supRepo.filterQueryList[_supRepo
.storeFilterList[index]
['filterQueryName']
.toString()]
.containsKey(_supRepo
.storeFilterList[index]
['options'][subIndex]
['id']
.toString()) ==
true
? childActiveStyle
: childStyle)
: childStyle),);
}));
},)]
));
}
如您所见,我正在尝试更改子文本的颜色。我在提供程序中执行此操作,但是如果不进行热重装,则看不到颜色变化。当我添加notifyListeners();
时,抽屉关闭。
Gif,你看..
解决方法
我的问题已解决,我通过删除scaffoldKey
解决了该错误,但是我不知道如何在没有scaffoldKey
的情况下以编程方式打开抽屉。.