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),
),
),
);
}
I want to bypass tabbar if page comes with tabbareanble = false but in this way Build Widget does not recognise tabbarenable variable.
ayn help?
CodePudding user response:
Because this is a StatefulWidget
, to access the parameter supplied to the widget in the State
's build method you'll need to access the parameter through the State
's widget property: widget.tabbarenable