Closed pradeep14598 closed 2 years ago
could u provide a minimal reproducible code?
On Tue, 22 Mar 2022 at 9:46 PM, Pk @.***> wrote:
E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
— Reply to this email directly, view it on GitHub https://github.com/sooxt98/google_nav_bar/issues/75, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A . You are receiving this because you are subscribed to this thread.Message ID: @.***>
could u provide a minimal reproducible code? … On Tue, 22 Mar 2022 at 9:46 PM, Pk @.> wrote: E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). — Reply to this email directly, view it on GitHub <#75>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A . You are receiving this because you are subscribed to this thread.Message ID: @.>
bottomNavigationBar: Container(
// height: kBottomNavigationBarHeight,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
blurRadius: 20,
color: Colors.black.withOpacity(.1),
)
],
),
child: SafeArea(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 8),
child: GNav(
rippleColor: AppColor.surfaceDisabled1,
hoverColor: AppColor.surfaceDisabled1,
gap: 4,
activeColor: AppColor.splash,
iconSize: 24,
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
tabBackgroundColor: AppColor.surfaceDisabled1,
color: AppColor.surfaceDisabled1,
tabs: [
GButton(
leading: Image.asset(
Images.tab1,
height: 24,
width: 24,
),
text: 'tab1'.tr,
textStyle: AppTextStyle.addBtnTxt
.copyWith(color: AppColor.primaryFontBlack),
icon: null,
),
GButton(
leading: Image.asset(
Images.tab2,
height: 24,
width: 24,
),
text: 'tab2'.tr,
textStyle: AppTextStyle.addBtnTxt
.copyWith(color: AppColor.primaryFontBlack),
icon: null,
),
GButton(
leading: Image.asset(
Images.tab3,
height: 24,
width: 24,
),
text: 'tab3'.tr,
textStyle: AppTextStyle.addBtnTxt
.copyWith(color: AppColor.primaryFontBlack),
icon: null,
),
GButton(
leading: Image.asset(
Images.tab4,
height: 24,
width: 24,
),
text: 'tab4'.tr,
textStyle: AppTextStyle.addBtnTxt
.copyWith(color: AppColor.primaryFontBlack),
icon: null,
),
],
selectedIndex: _selectedIndex,
onTabChange: (index) {
if (mounted)
setState(() {
_selectedIndex = index;
_onItemTapped(index);
});
},
),
),
),
),
I’m not able to run this, _onItemTapped is missing
On Tue, 22 Mar 2022 at 9:59 PM, Pk @.***> wrote:
could u provide a minimal reproducible code? … <#m587440306533223400> On Tue, 22 Mar 2022 at 9:46 PM, Pk @.> wrote: E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). — Reply to this email directly, view it on GitHub <#75 https://github.com/sooxt98/google_nav_bar/issues/75>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A . You are receiving this because you are subscribed to this thread.Message ID: @.>
bottomNavigationBar: Container( // height: kBottomNavigationBarHeight, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 20, color: Colors.black.withOpacity(.1), ) ], ), child: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 8), child: GNav( rippleColor: AppColor.surfaceDisabled1, hoverColor: AppColor.surfaceDisabled1, gap: 4, activeColor: AppColor.splash, iconSize: 24, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), tabBackgroundColor: AppColor.surfaceDisabled1, color: AppColor.surfaceDisabled1, tabs: [ GButton( leading: Image.asset( Images.tab1, height: 24, width: 24, ), text: 'tab1'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab2, height: 24, width: 24, ), text: 'tab2'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab3, height: 24, width: 24, ), text: 'tab3'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab4, height: 24, width: 24, ), text: 'tab4'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), ], selectedIndex: _selectedIndex, onTabChange: (index) { if (mounted) setState(() { _selectedIndex = index; _onItemTapped(index); }); }, ), ), ), ),
— Reply to this email directly, view it on GitHub https://github.com/sooxt98/google_nav_bar/issues/75#issuecomment-1075215407, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC2CGGW3Q2OT544LPNTVBHG2NANCNFSM5RK6EZ7A . You are receiving this because you commented.Message ID: @.***>
I’m not able to run this, _onItemTapped is missing … On Tue, 22 Mar 2022 at 9:59 PM, Pk @.> wrote: could u provide a minimal reproducible code? … <#m587440306533223400> On Tue, 22 Mar 2022 at 9:46 PM, Pk @.> wrote: E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). — Reply to this email directly, view it on GitHub <#75 <#75>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A . You are receiving this because you are subscribed to this thread.Message ID: @.> bottomNavigationBar: Container( // height: kBottomNavigationBarHeight, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 20, color: Colors.black.withOpacity(.1), ) ], ), child: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 8), child: GNav( rippleColor: AppColor.surfaceDisabled1, hoverColor: AppColor.surfaceDisabled1, gap: 4, activeColor: AppColor.splash, iconSize: 24, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), tabBackgroundColor: AppColor.surfaceDisabled1, color: AppColor.surfaceDisabled1, tabs: [ GButton( leading: Image.asset( Images.tab1, height: 24, width: 24, ), text: 'tab1'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab2, height: 24, width: 24, ), text: 'tab2'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab3, height: 24, width: 24, ), text: 'tab3'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab4, height: 24, width: 24, ), text: 'tab4'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), ], selectedIndex: _selectedIndex, onTabChange: (index) { if (mounted) setState(() { _selectedIndex = index; _onItemTapped(index); }); }, ), ), ), ), — Reply to this email directly, view it on GitHub <#75 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC2CGGW3Q2OT544LPNTVBHG2NANCNFSM5RK6EZ7A . You are receiving this because you commented.Message ID: @.>
List<Widget> _pages;
Widget _page1;
Widget _page2;
Widget _page3;
Widget _page4;
int _selectedIndex;
Widget _currentPage;
@override
void initState() {
super.initState();
_page1 = const Tab1();
_page2 = const Tab2();
_page3 = const Tab3();
_page4 = const Tab4();
_pages = [_page1, _page2, _page3, _page4];
_selectedIndex = 0;
_currentPage = _page1;
}
void _onItemTapped(int index) {
if (mounted)
setState(() {
_selectedIndex = index;
_currentPage = _pages[index];
});
}
Could you just send me a complete file that is runnable? currentPage Is missing
On Tue, 22 Mar 2022 at 10:06 PM, Pk @.***> wrote:
I’m not able to run this,
*onItemTapped is missing … <#m3194987528613587962> On Tue, 22 Mar 2022 at 9:59 PM, Pk @.*> wrote: could u provide a minimal reproducible code? … <#m_587440306533223400> On Tue, 22 Mar 2022 at 9:46 PM, Pk @.> wrote: E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). — Reply to this email directly, view it on GitHub <#75 https://github.com/sooxt98/google_nav_bar/issues/75 <#75 https://github.com/sooxt98/google_nav_bar/issues/75>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A . You are receiving this because you are subscribed to this thread.Message ID: @.> bottomNavigationBar: Container( // height: kBottomNavigationBarHeight, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 20, color: Colors.black.withOpacity(.1), ) ], ), child: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 8), child: GNav( rippleColor: AppColor.surfaceDisabled1, hoverColor: AppColor.surfaceDisabled1, gap: 4, activeColor: AppColor.splash, iconSize: 24, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), tabBackgroundColor: AppColor.surfaceDisabled1, color: AppColor.surfaceDisabled1, tabs: [ GButton( leading: Image.asset( Images.tab1, height: 24, width: 24, ), text: 'tab1'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab2, height: 24, width: 24, ), text: 'tab2'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab3, height: 24, width: 24, ), text: 'tab3'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab4, height: 24, width: 24, ), text: 'tab4'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), ], selectedIndex: _selectedIndex, onTabChange: (index) { if (mounted) setState(() { _selectedIndex = index; _onItemTapped(index); }); }, ), ), ), ), — Reply to this email directly, view it on GitHub <#75 (comment) https://github.com/sooxt98/google_nav_bar/issues/75#issuecomment-1075215407>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC2CGGW3Q2OT544LPNTVBHG2NANCNFSM5RK6EZ7A . You are receiving this because you commented.Message ID: @.>
void _onItemTapped(int index) { if (mounted) setState(() { _selectedIndex = index; _currentPage = _pages[index]; }); }
— Reply to this email directly, view it on GitHub https://github.com/sooxt98/google_nav_bar/issues/75#issuecomment-1075223858, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCECZ6TAIFJT4VL642PZ3VBHHU3ANCNFSM5RK6EZ7A . You are receiving this because you commented.Message ID: @.***>
Could you just send me a complete file that is runnable? currentPage Is missing … On Tue, 22 Mar 2022 at 10:06 PM, Pk @.> wrote: I’m not able to run this, onItemTapped is missing … <#m3194987528613587962> On Tue, 22 Mar 2022 at 9:59 PM, Pk @.*> wrote: could u provide a minimal reproducible code? … <#m_587440306533223400> On Tue, 22 Mar 2022 at 9:46 PM, Pk @.> wrote: E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). — Reply to this email directly, view it on GitHub <#75 <#75> <#75 <#75>>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A https://github.com/notifications/unsubscribe-auth/ADGCEC7AHFHPEMJLAFM7D73VBHFJ7ANCNFSM5RK6EZ7A . You are receiving this because you are subscribed to this thread.Message ID: @.> bottomNavigationBar: Container( // height: kBottomNavigationBarHeight, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 20, color: Colors.black.withOpacity(.1), ) ], ), child: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 8), child: GNav( rippleColor: AppColor.surfaceDisabled1, hoverColor: AppColor.surfaceDisabled1, gap: 4, activeColor: AppColor.splash, iconSize: 24, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), tabBackgroundColor: AppColor.surfaceDisabled1, color: AppColor.surfaceDisabled1, tabs: [ GButton( leading: Image.asset( Images.tab1, height: 24, width: 24, ), text: 'tab1'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab2, height: 24, width: 24, ), text: 'tab2'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab3, height: 24, width: 24, ), text: 'tab3'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), GButton( leading: Image.asset( Images.tab4, height: 24, width: 24, ), text: 'tab4'.tr, textStyle: AppTextStyle.addBtnTxt .copyWith(color: AppColor.primaryFontBlack), icon: null, ), ], selectedIndex: _selectedIndex, onTabChange: (index) { if (mounted) setState(() { _selectedIndex = index; _onItemTapped(index); }); }, ), ), ), ), — Reply to this email directly, view it on GitHub <#75 (comment) <#75 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCEC2CGGW3Q2OT544LPNTVBHG2NANCNFSM5RK6EZ7A . You are receiving this because you commented.Message ID: @.> void _onItemTapped(int index) { if (mounted) setState(() { _selectedIndex = index; _currentPage = _pages[index]; }); } — Reply to this email directly, view it on GitHub <#75 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGCECZ6TAIFJT4VL642PZ3VBHHU3ANCNFSM5RK6EZ7A . You are receiving this because you commented.Message ID: *@.>
https://gist.github.com/pradeep14598/b191d0bacd5ae9d67d1e6094152a4183
@pradeep14598 the DashboardController is missing, could you make it runnable first in one single file?
@pradeep14598 the DashboardController is missing, could you make it runnable first in one single file?
https://gist.github.com/pradeep14598/b191d0bacd5ae9d67d1e6094152a4183
@pradeep14598 you shouldnt put your final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
inside the build function
you should put at here
class Test extends StatefulWidget {
final String? title;
final GlobalKey<ScaffoldState> _scaffoldkey = new GlobalKey<ScaffoldState>();
Test({@required this.title});
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
@override
Widget build(BuildContext context) {
}
}
@pradeep14598 you shouldnt put your
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
inside the build functionyou should put at here
class Test extends StatefulWidget { final String? title; final GlobalKey<ScaffoldState> _scaffoldkey = new GlobalKey<ScaffoldState>(); Test({@required this.title}); @override _TestState createState() => _TestState(); } class _TestState extends State<Test> { @override Widget build(BuildContext context) { } }
Hai @sooxt98 ,Thanks for your solution and your awesome plugin ,is there any feature for adding badges in tab
@pradeep14598 you could look into this badge example https://github.com/sooxt98/google_nav_bar/blob/master/example/lib/main_advance.dart
E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().