rafalbednarczuk / curved_navigation_bar

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

error : _bottomNavigationKey.currentState; #87

Closed Krahost closed 3 years ago

Krahost commented 3 years ago

I am try to implement the bottom in my project and i keep getting this error, please help me fix it

_bottomNavigationKey.currentState;

image

rafalbednarczuk commented 3 years ago

https://pub.dev/packages/curved_navigation_bar/example Here is how to use _bottomNavigationKey

pt., 20 lis 2020 o 19:09 Krahost notifications@github.com napisał(a):

I am try to implement the bottom in my project and i keep getting this error, please help me fix it

_bottomNavigationKey.currentState;

[image: image] https://user-images.githubusercontent.com/33775619/99834271-48bb6580-2b9e-11eb-9e57-d7f875bf230c.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rafalbednarczuk/curved_navigation_bar/issues/87, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLCK5JCHTHCPUTNP4IBZJDSQ2WHLANCNFSM4T5C47EA .

Krahost commented 3 years ago

I COPIED THIS WHOLE CODE AND ADDED THE PACKAGE TO MY PUBSPEC.YAML FILE and i got this same error: below is the code :

import 'package:flutter/material.dart'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'

void main() => runApp(MaterialApp(home: BottomNavBar()));

class BottomNavBar extends StatefulWidget { @override _BottomNavBarState createState() => _BottomNavBarState(); }

class _BottomNavBarState extends State { int _page = 0; GlobalKey _bottomNavigationKey = GlobalKey();

@override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: CurvedNavigationBar( key: _bottomNavigationKey, index: 0, height: 50.0, items: [ 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) { setState(() { _page = index; }); }, ), body: Container( color: Colors.blueAccent, child: Center( child: Column( children: [ Text(_page.toString(), textScaleFactor: 10.0), RaisedButton( child: Text('Go To Page of index 1'), onPressed: () { final CurvedNavigationBarState navBarState = _bottomNavigationKey.currentState; navBarState.setPage(1); }, ) ], ), ), )); } }

rafalbednarczuk commented 3 years ago

you didn't copy the whole *example/example.dart <https://github.com/rafalbednarczuk/curved_navigation_bar/blob/master/example/example.dart>* file. Your code is different

pt., 20 lis 2020 o 20:18 Krahost notifications@github.com napisał(a):

I COPIED THIS WHOLE CODE AND ADDED THE PACKAGE TO MY PUBSPEC.YAML FILE and i got this same error: below is the code :

import 'package:flutter/material.dart'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'

void main() => runApp(MaterialApp(home: BottomNavBar()));

class BottomNavBar extends StatefulWidget { @override https://github.com/override _BottomNavBarState createState() => _BottomNavBarState(); }

class _BottomNavBarState extends State { int _page = 0; GlobalKey _bottomNavigationKey = GlobalKey();

@override https://github.com/override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: CurvedNavigationBar( key: _bottomNavigationKey, index: 0, height: 50.0, items: [ 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) { setState(() { _page = index; }); }, ), body: Container( color: Colors.blueAccent, child: Center( child: Column( children: [ Text(_page.toString(), textScaleFactor: 10.0), RaisedButton( child: Text('Go To Page of index 1'), onPressed: () { final CurvedNavigationBarState navBarState = _bottomNavigationKey.currentState; navBarState.setPage(1); }, ) ], ), ), )); } }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rafalbednarczuk/curved_navigation_bar/issues/87#issuecomment-731360362, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLCK5IAADTBJJWM6XJJHHDSQ26I5ANCNFSM4T5C47EA .