skip to Main Content

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
      ),
    );

2

Answers


  1. You can perform a condition check to do this:

    
    floatingActionButton : (title.isNotEmpty)?_playerControl(context) : null,
    
    Login or Signup to reply.
  2. Try this

        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 : (title.isNotEmpty)?_playerControl(context) : null,
                  //this contains the mini 
                  player. I want this to be hidden or present based upon the value received 
                  by url argument
              ),
            );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search