If you want to extend PageView to both sides with builder? Use PageController’s initialPage property. Setting it to an absurdly big value. And then use this value as your “index 0”.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
class MyHomePage extends StatelessWidget { final PageController pageController = new PageController(initialPage: 4242); @override Widget build(BuildContext context) { return new Scaffold(body: new PageView.builder( controller: pageController, itemBuilder: (context, _index) { final index = _index - 4242; return new Container( margin: const EdgeInsets.all(9.0), color: Colors.red, child: new Center( child: new Text(index.toString()), ), ); }, )); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.