-
-
Save MarcinusX/c56f9da577e1ea62a4ac2382028005f3 to your computer and use it in GitHub Desktop.
This file contains 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
class _SlidingCardsViewState extends State<SlidingCardsView> { | |
PageController pageController; | |
double pageOffset = 0; | |
@override | |
void initState() { | |
super.initState(); | |
pageController = PageController(viewportFraction: 0.8); | |
pageController.addListener(() { | |
setState(() => pageOffset = pageController.page); //<-- add listener and set state | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return ... | |
[ | |
SlidingCard( | |
name: 'Shenzhen GLOBAL DESIGN AWARD 2018', | |
date: '4.20-30', | |
assetName: 'steve-johnson.jpeg', | |
offset: pageOffset, //<-- pass offset | |
), | |
SlidingCard( | |
name: 'Dawan District, Guangdong Hong Kong and Macao', | |
date: '4.28-31', | |
assetName: 'rodion-kutsaev.jpeg', | |
offset: pageOffset - 1, //<-- pass offset - indexOfCard | |
), | |
] | |
...; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment