Created
July 7, 2023 15:48
-
-
Save romanejaquez/1c72fda67c98374e72e88e500ae63ca1 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(const PageViewApp()); | |
} | |
class PageViewApp extends StatelessWidget { | |
const PageViewApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: PageViewMainPage(), | |
); | |
} | |
} | |
class PageViewMainPage extends StatefulWidget { | |
const PageViewMainPage({super.key}); | |
@override | |
State<PageViewMainPage> createState() => _PageViewMainPageState(); | |
} | |
class _PageViewMainPageState extends State<PageViewMainPage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: PageView( | |
children: List.generate(10, (index) { | |
return PageViewSinglePage(); | |
}) | |
), | |
); | |
} | |
} | |
class PageViewSinglePage extends StatefulWidget { | |
const PageViewSinglePage({super.key}); | |
@override | |
State<PageViewSinglePage> createState() => _PageViewSinglePageState(); | |
} | |
class _PageViewSinglePageState extends State<PageViewSinglePage> { | |
ScrollController pageScroll = ScrollController(); | |
double scaleValue = 1.0; | |
@override | |
void initState() { | |
super.initState(); | |
pageScroll.addListener(() { | |
debugPrint(pageScroll.offset.toString()); | |
setState(() { | |
scaleValue = pageScroll.offset > 0 ? (1 + (pageScroll.offset * 0.0005)) : 1; | |
}); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return SingleChildScrollView( | |
controller: pageScroll, | |
child: Transform.scale( | |
scale: scaleValue, | |
alignment: Alignment.bottomCenter, | |
child: Container( | |
margin: const EdgeInsets.all(20.0), | |
child: Column( | |
children: [ | |
const SizedBox(height: 70), | |
Text('Main Story Title', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)), | |
const SizedBox(height: 10), | |
...List.generate(10, (index) { | |
return Column( | |
children: [ | |
Container( | |
height: 100, | |
color: Colors.grey | |
), | |
Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.') | |
], | |
); | |
}) | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment