Created
November 8, 2023 21:40
-
-
Save tech-andgar/ccd058a4aab201a0e4bc6c2d6f7cfa81 to your computer and use it in GitHub Desktop.
bug render flutter
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
import 'package:flutter/material.dart'; | |
class NewWidget extends StatefulWidget { | |
const NewWidget({super.key}); | |
@override | |
State<NewWidget> createState() => _NewWidgetState(); | |
} | |
class _NewWidgetState extends State<NewWidget> { | |
final PageController _controller = PageController(viewportFraction: 0.8); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: SizedBox( | |
height: 100, // Card height | |
child: PageView.builder( | |
itemCount: 10, | |
controller: _controller, | |
itemBuilder: (context, index) { | |
return ListenableBuilder( | |
listenable: _controller, | |
builder: (context, child) { | |
double factor = 1; | |
if (_controller.position.hasContentDimensions) { | |
factor = 1 - (_controller.page! - index).abs(); | |
} | |
return Center( | |
child: SizedBox( | |
height: 70 + (factor * 30), | |
child: Card( | |
elevation: 4, | |
child: Center(child: Text('Card $index')), | |
), | |
), | |
); | |
}, | |
); | |
}, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment