Open realapril opened 2 years ago
Could you provide a minimal code that produce this error?
While using Navigator.of(context).popAndPushNamed(); inside the onTabChnage() callback throws the above error please check this. The same works fine if pushNamed is been used. It's a common case where developers can try to navigate to another page on tab change right? Correct me if i am using it wrong
@Blisston you could use GButton onPressed
for Navigator, onTabChnage usually is used for setState
to change tab content
It does the same issue on onPressed function
Could you provide a minimal code that produce this error?
On Fri, 27 May 2022 at 8:59 PM, alexandranb1 @.***> wrote:
It does the same issue on onPressed function
— Reply to this email directly, view it on GitHub https://github.com/sooxt98/google_nav_bar/issues/69#issuecomment-1139595350, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC6II2RAFMZM6XQF7VLVMDBJNANCNFSM5GIMQT5Q . You are receiving this because you commented.Message ID: @.***>
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19043.1706], locale en-US) • Flutter version 2.10.3 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (3 months ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.16.1 • DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) And I have a Stateful widget, and in the body I have the clasic GNav and all of the tabs look like this : GButton( icon: Icons.perm_identity_sharp, text: 'Profile', onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const Profile())); } ),
Hi there, I need the full code all in one file, at least it’s runnable, and able to reproduce the same error
On Fri, 27 May 2022 at 9:09 PM, alexandranb1 @.***> wrote:
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19043.1706], locale en-US) • Flutter version 2.10.3 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (3 months ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.16.1 • DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) And I have a Stateful widget, and in the body I have the clasic GNav and all of the tabs look like this : GButton( icon: Icons.perm_identity_sharp, text: 'Profile', onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const Profile())); } ),
— Reply to this email directly, view it on GitHub https://github.com/sooxt98/google_nav_bar/issues/69#issuecomment-1139603738, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC57SDPCFJLLLS36RX3VMDCSFANCNFSM5GIMQT5Q . You are receiving this because you commented.Message ID: @.***>
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: const NavigationError(),
);
}
}
class NavigationError extends StatelessWidget {
const NavigationError({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
int selectedIndex = 0;
return Scaffold(
body: Center(child: Text('Home')),
bottomNavigationBar: Container(
decoration: BoxDecoration(
color: Color(0xFFDFDFDF),
boxShadow: [
BoxShadow(
blurRadius: 20,
color: Colors.black.withOpacity(.1),
)
],
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 100.0, vertical: 10),
child: GNav(
rippleColor: Colors.grey[300]!,
hoverColor: Colors.grey[100]!,
gap: 1,
activeColor: Colors.black,
iconSize: 24,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
duration: Duration(milliseconds: 500),
tabBackgroundColor: Theme.of(context).colorScheme.surface,
color: Colors.black,
tabs: [
GButton(
icon: Icons.home,
text: 'Home',
onPressed: () {
Navigator.pushReplacement(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const DashboardScreen(),
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero));
},
),
GButton(
icon: Icons.person,
text: 'Profile',
onPressed: (){
Navigator.pushReplacement(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const ProfileScreen(),
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero));
},
),
],
selectedIndex: selectedIndex,
),
),
),
);
}
}
@sooxt98 this code can give you exceptions
First of all, I love your designed navigation widget. However there is a minor error when I use Navigator function
Navigator.of(context).pushReplacementNamed
, this error occurs. UsingNavigator.of(context).pushNamed
is fine.It doesn't kill an application so it might be a minor problem for now, but I think it will be a pain later.