there. I'm starting to learn animation in Flutter and I don't know how to make the listview of item appear automatically like this video: see this video
CodePudding user response:
Take a look at the PageView class.
For Autoscrolling you can checkout Timer and PageController
This is sample way of how you can achieve that:
Declare the Controller and Page Number
int _currentPage = 0;
PageController _pageController = PageController(
initialPage: 0,
);
Initiating the Timer and then navigating to the next item using PageController
@override
void initState() {
super.initState();
Timer.periodic(Duration(seconds: 5), (Timer timer) {
if (_currentPage < 2) {
_currentPage ;
} else {
_currentPage = 0;
}
_pageController.animateToPage(
_currentPage,
duration: Duration(milliseconds: 350),
curve: Curves.easeIn,
);
});
}
Finally calling the build method with the view
@override
Widget build(BuildContext context) {
return PageView(
controller: _pageController,
children: [
Container(
child: Text("1"),
),
Container(
child: Text("2"),
),
Container(
child: Text("3"),
),
],
);
}
CodePudding user response:
You can use this package(https://pub.dev/packages/flutter_banner_swiper). Or take a look at this repository and make ur custom with help of it.
There's also another package with null-safety(https://pub.dev/packages/banner_carousel)