Home > Net >  show/hide widget based upon the value present
show/hide widget based upon the value present

Time:08-11

I have a floating action button that contains mini player and i want it to be hidden if the value like music path or title is not present but only show up if somebody passes the data or presses the songs. For example if How would I be able to achieve that ?

child:  Scaffold(
        floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
        extendBody: true,
        body: screens[index],
        bottomNavigationBar: Theme(
          data: Theme.of(context)
              .copyWith(iconTheme: IconThemeData(color: Colors.white)),
          child: CurvedNavigationBar(
            items: items,
            index: index,
            height: 55,
            color: Colors.indigo,
            backgroundColor: Colors.white,
            buttonBackgroundColor: Colors.indigo,
            onTap: (index) => setState(() => this.index = index),
          ),
        ),
        floatingActionButton: _playerControl(context), //this contains the mini 
          player. I want this to be hidden or present based upon the value received 
          by url argument
      ),
    );

CodePudding user response:

You can perform a condition check to do this:


floatingActionButton : (title.isNotEmpty)?_playerControl(context) : null,
  • Related