Skip to content

Instantly share code, notes, and snippets.

@liudonghua123
Created April 25, 2020 08:20
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 liudonghua123/65e608a943f2b115db87e2c438548ced to your computer and use it in GitHub Desktop.
Save liudonghua123/65e608a943f2b115db87e2c438548ced to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SamplePage(),
),
);
}
}
class SamplePage extends StatefulWidget {
SamplePage({Key key}) : super(key: key);
@override
_SamplePageState createState() => _SamplePageState();
}
class _SamplePageState extends State<SamplePage>
with SingleTickerProviderStateMixin {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
actions: <Widget>[
Material(
color: Colors.transparent,
child: InkWell(
onTap: () {},
child: IconButton(
icon: Icon(Icons.access_alarm),
onPressed: () {},
),
),
),
],
title: Text('SliverAppBar'),
backgroundColor: Theme.of(context).accentColor,
expandedHeight: 200.0,
flexibleSpace: FlexibleSpaceBar(
background: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.blue, Colors.green],
)),
),
),
// floating: floating,
// snap: snap,
pinned: true,
),
SliverList(
delegate:
SliverChildBuilderDelegate((BuildContext context, int index) {
if (index > 30) {
return null;
}
return ListTile(
title: Text('item ${index.toString()}'),
onTap: () {},
);
}),
// delegate: SliverChildListDelegate(
// List.generate(30, (int index) {
// return ListTile(title: Text('item ${index.toString()}'),onTap: (){},);
// }),
// ),
),
],
),
);
}
}
@liudonghua123
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment