hi @jonataslaw
first I wanna say thank you for great package Get,
as you said "Forget StatefulWidget", but how we create GetController for Animation Controller where we need TickerProviderStateMixin ?
example :
class BottomBarView extends StatefulWidget {
@override
_BottomBarViewState createState() => _BottomBarViewState();
}
class _BottomBarViewState extends State<BottomBarView>
with TickerProviderStateMixin {
AnimationController animationController;
@override
void initState() {
animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1000),
);
animationController.forward();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
);
}
}
hi @jonataslaw
first I wanna say thank you for great package Get,as you say "Forget StatefulWidget", but how we create GetController for Animation Controller where we need TickerProviderStateMixin ?
example :
class BottomBarView extends StatefulWidget {
@override
_BottomBarViewState createState() => _BottomBarViewState();
}
class _BottomBarViewState extends State
with TickerProviderStateMixin {
AnimationController animationController;
@override
void initState() {
animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1000),
);
animationController.forward();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
);
}
}
Actually there is no problem using StatefulWidget, but I needed to draw some attention to this, because in an app with a single FlatButton on the desktop Flutter that is now open, a StatelessWidget consumes 1mb and the same StatefulWidget class consumes 2mb. The difference is exactly double, so reducing the number of classes with StatefulWidget can significantly improve RAM consumption.
However, if one of the requirements of the class is to use StatefulWidget, there will be no problem using it, I would just say to create a separate widget for this component to make your code more readable and that is exactly what you did. Great!
I needed vsync to setup a controller for the tabbar, and looked inside the get package code and what worked with me is:
vsync: Navigator()
I needed vsync to setup a controller for the tabbar, and looked inside the get package code and what worked with me is:
vsync: Navigator()
For me is TabController tabController = TabController(length: 10, vsync: NavigatorState());
Hope can help someone :+1:
I needed vsync to setup a controller for the tabbar, and looked inside the get package code and what worked with me is:
vsync: Navigator()For me is
TabController tabController = TabController(length: 10, vsync: NavigatorState());Hope can help someone 馃憤
@ghprod, you saved my life bro :)
Most helpful comment
For me is
TabController tabController = TabController(length: 10, vsync: NavigatorState());Hope can help someone :+1: