Skip to content

Instantly share code, notes, and snippets.

@Rahiche
Created August 11, 2018 23:53
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Rahiche/e290d4a07deb24264f8c0dddcb946b35 to your computer and use it in GitHub Desktop.
Save Rahiche/e290d4a07deb24264f8c0dddcb946b35 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(home: new MyApp()));
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String img1 =
"https://images.pexels.com/photos/531880/pexels-photo-531880.jpeg?auto=compress&cs=tinysrgb&h=350";
String img2 =
"https://images.pexels.com/photos/262438/pexels-photo-262438.jpeg?auto=compress&cs=tinysrgb&h=350";
String img3 =
"https://images.pexels.com/photos/865002/pexels-photo-865002.jpeg?auto=compress&cs=tinysrgb&h=350";
String img4 =
"https://images.pexels.com/photos/39397/dart-target-aim-arrow-39397.jpeg?auto=compress&cs=tinysrgb&h=350";
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
reverse: true,
slivers: <Widget>[
MyAppBar(
imgUrl: img1,
),
MyAppBar(
imgUrl: img2,
),
MyAppBar(
imgUrl: img3,
),
MyAppBar(
imgUrl: img4,
),
SliverFillRemaining(
child: Container(),
)
],
),
);
}
}
class MyAppBar extends StatelessWidget {
final String imgUrl;
const MyAppBar({
Key key,
this.imgUrl,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SliverAppBar(
expandedHeight: 250.0,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
background: Image.network(
imgUrl,
fit: BoxFit.cover,
),
title: const Text('You must see this'),
centerTitle: true,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment