Skip to content

Instantly share code, notes, and snippets.

@erluxman
Created April 21, 2020 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erluxman/6874032a7a1ea129640b8f617f7ffed3 to your computer and use it in GitHub Desktop.
Save erluxman/6874032a7a1ea129640b8f617f7ffed3 to your computer and use it in GitHub Desktop.
SliverAppbar
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(body: SliverAppBarDemo()),
);
}
}
class SliverAppBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text(
"SilverAppBar title",
),
snap: true,
floating: true,
pinned: true,
stretch: true,
//Max height of background Image
expandedHeight: 160.0,
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
background: Image.network(
"https://cdn.pixabay.com/photo/2017/09/14/22/42/milky-way-2750627__340.jpg",
fit: BoxFit.fill,
),
),
),
// SliverList(
SliverFillRemaining(
child: Center(child: Text("Body")),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment