class CategoryViewDetail extends StatefulWidget {
const CategoryViewDetail({Key? key, required bool tabbarenable})
: super(key: key);
@override
Widget build(BuildContext context) {
List<Tab> tabs = <Tab>[];
return FutureBuilder<Categories>(
future: _futureCategories,
builder: (BuildContext context, AsyncSnapshot<Categories> snapshot) {
if (snapshot.hasData) {
final name = snapshot.data?.data;
var filteredList = name
?.where((name) =>
name.name == 'Spor' ||
.toList();
//here I want to hide tabbar if the page comes with CategoryViewDetail(tabbarenable: false)
for (int i = 0; i < filteredList!.length; i ) {
tabs.add(
Tab(
child: Text(
' ${filteredList[i].name}',
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 15.0,
fontFamily: 'Manrope',
color: Colors.black54),
),
),
);
}
如果頁面帶有 tabbareanble = false ,我想繞過 tabbar 但這樣 Build Widget 無法識別 tabbarenable 變數。
艾恩幫助?
uj5u.com熱心網友回復:
因為這是StatefulWidget, 要訪問在State的構建方法中提供給小部件的引數,您需要通過State的小部件屬性訪問引數:widget.tabbarenable
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/334724.html
