Created
April 25, 2020 08:20
-
-
Save liudonghua123/65e608a943f2b115db87e2c438548ced to your computer and use it in GitHub Desktop.
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(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: (){},); | |
// }), | |
// ), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://dartpad.cn/65e608a943f2b115db87e2c438548ced