Created
July 24, 2020 01:56
-
-
Save dhruvilp/25c14a9752877d50491cd96b0926e21a to your computer and use it in GitHub Desktop.
SliverAppBar + FlexibleSpaceBar
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'; | |
void main() => runApp(MaterialApp(home: MyApp())); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: CustomScrollView( | |
physics: const BouncingScrollPhysics(), | |
slivers: <Widget>[ | |
SliverAppBar( | |
stretch: true, | |
floating: false, | |
pinned: true, | |
snap: false, | |
onStretchTrigger: () { | |
// Function callback for stretch | |
return; | |
}, | |
expandedHeight: MediaQuery.of(context).size.height, | |
flexibleSpace: FlexibleSpaceBar( | |
stretchModes: <StretchMode>[ | |
StretchMode.zoomBackground, | |
StretchMode.blurBackground, | |
StretchMode.fadeTitle, | |
], | |
centerTitle: true, | |
title: const Text('Flight Report'), | |
background: Stack( | |
fit: StackFit.expand, | |
children: [ | |
Image.network( | |
'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg', | |
fit: BoxFit.cover, | |
), | |
const DecoratedBox( | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
begin: Alignment(0.0, 0.5), | |
end: Alignment(0.0, 0.0), | |
colors: <Color>[ | |
Color(0x60000000), | |
Color(0x00000000), | |
], | |
), | |
), | |
), | |
], | |
), | |
), | |
), | |
SliverList( | |
delegate: SliverChildBuilderDelegate( | |
(BuildContext context, int index) { | |
return ListTile( | |
leading: Icon(Icons.wb_sunny), | |
title: Text('Day ${index+1}'), | |
subtitle: Text( | |
'sunny, h: ${62+index}, l: ${54+index}', | |
), | |
); | |
}, | |
childCount: 30, | |
), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment