i have this class :
class BottomNavBar extends StatefulWidget {
final int activeTabIndex;
const BottomNavBar({Key? key, required this.activeTabIndex})
: super(key: key);
@override
BottomNavBarState createState() => BottomNavBarState();
}
class BottomNavBarState extends State<BottomNavBar> {
static bool isCollapsed = false;
@override
Widget build(BuildContext context) {
Scaffold(
body: SlidingUpPanel(
controller: _pc,
panelBuilder: (sc) {
setState(() {
isCollapsed ? _pc.show(): _pc.hide();
});
return Container(
child: Center(child: Text("Panel")),
);
},
body: Text("something");
), }
}
and I want to change value of variable isCollapsed
in this class:
class _PlayerPreviewState extends State<PlayerPreview> {
@override
Widget build(BuildContext context) {
final String play = 'assets/icons/play.svg';
var pageWidth = MediaQuery.of(context).size.width;
return Padding(
padding: EdgeInsets.only(top: pageWidth * .04),
child: IconButton(
onPressed: () {
BottomNavBarState.isCollapsed = true;
},
icon: SvgPicture.asset(play),
),
);}}
I want to when clicking on IconButton, isCollapsed is change to true.
and when I've print BottomNavBarState.isCollapsed
, print true and its change.
but in BottomNavBarState not change . and this part -> if (isCollapsed == true) _pc.show();
not work.
I know I should do it with the statement manager, but I don't know about them.
so can anyone help me please? how can I change isCollaps and run _pc.show()