Created
June 22, 2021 22:44
-
-
Save IsmailAlamKhan/1934c3f667343be27e812034b7f0d1b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return const MaterialApp( | |
title: 'Material App', | |
home: Home(), | |
); | |
} | |
} | |
class Home extends StatefulWidget { | |
const Home({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
_HomeState createState() => _HomeState(); | |
} | |
class _HomeState extends State<Home> { | |
final pageController = PageController(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('Material App Bar'), | |
), | |
bottomNavigationBar: ElevatedButton( | |
onPressed: () { | |
/* | |
pageController.animateToPage( | |
(pageController.page! + 1).round(), | |
duration: const Duration(milliseconds: 500), | |
curve: Curves.easeInOut, | |
); | |
*/ | |
pageController.animateTo( | |
pageController.page! + 1, | |
duration: const Duration(milliseconds: 500), | |
curve: Curves.easeInOut, | |
); | |
}, | |
child: Icon(Icons.skip_next), | |
), | |
body: PageView.builder( | |
controller: pageController, | |
itemBuilder: (context, index) => Center( | |
child: Text('Item $index'), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment