Skip to content

Instantly share code, notes, and snippets.

@HansMuller
Created July 14, 2017 21:52
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 HansMuller/facae02ce97892eaa2f159ea50c45e61 to your computer and use it in GitHub Desktop.
Save HansMuller/facae02ce97892eaa2f159ea50c45e61 to your computer and use it in GitHub Desktop.
// See https://github.com/flutter/flutter/issues/11222
import 'package:flutter/material.dart';
class TestPage2 extends StatefulWidget {
@override
_TestPageState2 createState() => new _TestPageState2();
}
class _TestPageState2 extends State<TestPage2> {
Widget _buildItem(BuildContext context, int index) {
return new ListTile(
title: new Text('Title $index'),
subtitle: new Text('Subtitle $index'),
);
}
Widget _buildTab(int listSize, String title) {
return new Stack(
children: <Widget>[
new Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: new Material(
elevation: 4.0,
color: Colors.white,
child: new Container(
height: 48.0,
child: new Center(
child: new Text('$title Header'),
),
),
),
),
new Positioned(
top: 48.0,
left: 0.0,
right: 0.0,
bottom: 0.0,
child: new RefreshIndicator(
onRefresh: () {},
child: new ListView.builder(
key: new PageStorageKey<String>(title),
itemBuilder: _buildItem,
itemCount: 12,
),
),
),
],
);
}
@override
Widget build(BuildContext context) {
return new DefaultTabController(
length: 2,
child: new Scaffold(
body: new NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return [
new SliverAppBar(
expandedHeight: 256.0,
backgroundColor: Colors.black26,
title: new Text('App Title'),
pinned: true,
floating: true,
bottom: new TabBar(
tabs: [
new Tab(text: 'Tab1'),
new Tab(text: 'Tab2'),
]
),
),
];
},
body: new TabBarView(
children: [
_buildTab(32, 'Tab 1'),
_buildTab(16, 'Tab 2'),
],
),
),
),
);
}
}
void main() {
runApp(new MaterialApp(home: new TestPage2()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment