Created
July 27, 2022 10:58
-
-
Save AlexeyBukin/b76176f3d968c0fd4331e7f5b8846905 to your computer and use it in GitHub Desktop.
pageview_in_appbar
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'; | |
| import 'package:flutter/physics.dart'; | |
| main() { | |
| runApp( | |
| MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| home: PhysicsCardDragDemo(), | |
| ), | |
| ); | |
| } | |
| class PhysicsCardDragDemo extends StatelessWidget { | |
| final items = [Colors.black, Colors.pink]; | |
| static const imageRatio = 375 / 500; | |
| @override | |
| Widget build(BuildContext context) { | |
| final screenWidth = MediaQuery.of(context).size.width; | |
| return Scaffold( | |
| body: CustomScrollView( | |
| slivers: <Widget>[ | |
| SliverAppBar( | |
| expandedHeight: screenWidth / imageRatio, | |
| surfaceTintColor: Colors.white, | |
| stretch: true, | |
| pinned: true, | |
| flexibleSpace: FlexibleSpaceBar( | |
| background: SafeArea( | |
| child: PageView.builder( | |
| scrollDirection: Axis.vertical, | |
| itemBuilder: (__, index) => | |
| Container(height: 300, color: items[index]), | |
| itemCount: items.length, | |
| ), | |
| ), | |
| ), | |
| ), | |
| SliverToBoxAdapter( | |
| child: Container( | |
| height: 3000, | |
| color: Colors.green, | |
| ), | |
| ), | |
| ], | |
| )); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment