rafalbednarczuk / curved_navigation_bar

Animated Curved Navigation Bar in Flutter
BSD 2-Clause "Simplified" License
694 stars 242 forks source link

Initiate State #143

Closed abdollah3d closed 5 months ago

abdollah3d commented 1 year ago

is it possible to start from a different index than the most left one? like app does what this button do at start

ElevatedButton( child: Text('Go To Page of index 2'), onPressed: () { final CurvedNavigationBarState? navBarState = _bottomNavigationKey.currentState; navBarState?.setPage(2); }, )

rafalbednarczuk commented 5 months ago

Yes, use index property of the widget. Example:

CurvedNavigationBar(
          key: _bottomNavigationKey,
          index: 3,
          items: <Widget>[
            Icon(Icons.add, size: 30),
            Icon(Icons.list, size: 30),
            Icon(Icons.compare_arrows, size: 30),
            Icon(Icons.call_split, size: 30),
            Icon(Icons.perm_identity, size: 30),
          ],
          color: Colors.white,
          buttonBackgroundColor: Colors.white,
          backgroundColor: Colors.blueAccent,
          animationCurve: Curves.easeInOut,
          animationDuration: Duration(milliseconds: 600),
          onTap: (index) {

          },
          letIndexChange: (index) => true,
        )