Skip to content

Instantly share code, notes, and snippets.

@AlexeyBukin
Created July 27, 2022 10:58
Show Gist options
  • Select an option

  • Save AlexeyBukin/b76176f3d968c0fd4331e7f5b8846905 to your computer and use it in GitHub Desktop.

Select an option

Save AlexeyBukin/b76176f3d968c0fd4331e7f5b8846905 to your computer and use it in GitHub Desktop.
pageview_in_appbar
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