Home > front end >  how to create sidemenu in android tv using Flutter?
how to create sidemenu in android tv using Flutter?

Time:10-13

enter image description here

how to add this side-menu in the android tv app using flutter and how to handle its focus.

I'm using flutter 3.0.0

CodePudding user response:

there is a pre-built widget that you can use in order to achieve that navigation NavigationRail

you can implement it like this :

 NavigationRail(
          selectedIndex: _selectedIndex,
          groupAlignment: groupAligment,
          onDestinationSelected: (int index) {
            setState(() {
              _selectedIndex = index;
            });
          },
          labelType: labelType,
          leading: showLeading
              ? FloatingActionButton(
                  elevation: 0,
                  onPressed: () {
                    // Add your onPressed code here!
                  },
                  child: const Icon(Icons.add),
                )
              : const SizedBox(),
          trailing: showTrailing
              ? IconButton(
                  onPressed: () {
                    // Add your onPressed code here!
                  },
                  icon: const Icon(Icons.more_horiz_rounded),
                )
              : const SizedBox(),
          destinations: const <NavigationRailDestination>[
            NavigationRailDestination(
              icon: Icon(Icons.favorite_border),
              selectedIcon: Icon(Icons.favorite),
              label: Text('First'),
            ),
            NavigationRailDestination(
              icon: Icon(Icons.bookmark_border),
              selectedIcon: Icon(Icons.book),
              label: Text('Second'),
            ),
            NavigationRailDestination(
              icon: Icon(Icons.star_border),
              selectedIcon: Icon(Icons.star),
              label: Text('Third'),
            ),
          ],
        ),
  • Related