return DefaultTabController(
length: filteredList.length,
child: Scaffold(
appBar: AppBar(
backgroundColor: (Colors.white),
iconTheme: const IconThemeData(color: Colors.black),
title: Transform.translate(
offset: const Offset(-24.0, 0.0),
child: Image.asset("assets/images/logo.png",
fit: BoxFit.contain, height: 22),
),
bottom: PreferredSize(
preferredSize: widget.tabbarenable
? const Size.fromHeight(30.00)
: const Size.fromHeight(0.00),
child: ColoredBox(
color: Colors.white,
child: Column(
children: [
widget.tabbarenable
? TabBar(
labelColor: Colors.purple[100],
indicatorColor: Colors.purple,
isScrollable: true,
labelPadding:
const EdgeInsets.symmetric(horizontal: 8.0),
tabs: tabs)
: Container()
],
),
),
),
),
I am deciding Tabbar enable or disable with boolen value: tabbarenable but this is not suitable for my solution because everytime I have to run whole page only disable to the Tabbar.
Now I decided to use GetX now but when I enter it: Obx( () =>
to bottom: PreferredSize I am getting this error `The argument type 'Obx' can't be assigned to the parameter type 'PreferredSizeWidget?'``
any help?
CodePudding user response:
Well AppBar
bottom takes argument of type PreferredSizeWidget
So you cannot assign Obx Directly with it. So you either have to use your own custom app bar, use Obx
inside the widget or bellow code that is to create a custom widget that takes action for you by implementing PrefferedSizeWidget
. Note: this will still require you to give it a preferredSize for compulsion.
class BottomOfAppBar extends StatelessWidget implements PreferredSizeWidget {
const BottomOfAppBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Obx(() => Container());
}
@override
Size get preferredSize => Size.fromHeight(55.0);
}