'How to place Widget in destination in NavigationRail

I would like to know how to place a List<Widget> in destinations in NavigationRail

  Widget build(BuildContext context) {
    return NavigationRail(
      minWidth: width,
      selectedIndex: currentPageIndex,
      labelType: NavigationRailLabelType.all,
      onDestinationSelected: _setIndex,
      destinations: const [
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.home_rounded),
            label: 'Home',
          ), 
          index: 0,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.explore),
            label: 'Explore',
          ),
          index: 1,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
          icon: Icon(Icons.bookmark),
          label: 'Saved',
        ),
          index: 2,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.mail_rounded),
            label: 'Messages',
          ),
          index: 3,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.person_rounded),
            label: 'Profile',
          ),
          index: 4,
        ),
      ]
    );
  }

But NavigationRail {required List<NavigationRailDestination> destinations}. so I can’t place Widget.

I’d like to know how to change this to be able to place a Widget.

Error:The element type 'Container' can't be assigned to the list type 'NavigationRailDestination'.

as on NavigationBar

  Widget build(BuildContext context) {
    return NavigationBar(
      selectedIndex: currentPageIndex,
      labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
      onDestinationSelected: setIndex,
      height: height,
      destinations: [
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.home_rounded),
            label: 'Home',
          ), 
          index: 0,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.explore),
            label: 'Explore',
          ),
          index: 1,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
          icon: Icon(Icons.bookmark),
          label: 'Saved',
        ),
          index: 2,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.mail_rounded),
            label: 'Messages',
          ),
          index: 3,
        ),
        animatedNavigationItem(
          child: const NavigationDestination(
            icon: Icon(Icons.person_rounded),
            label: 'Profile',
          ),
          index: 4,
        ),
      ],
    );
  }

{required List<Widget> destinations}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source