import 'package:flutter/material.dart';
class NestedScrollViewWithTabBarExample extends StatefulWidget {
@override
_NestedScrollViewWithTabBarExampleState createState() => _NestedScrollViewWithTabBarExampleState();
}
class _NestedScrollViewWithTabBarExampleState extends State<NestedScrollViewWithTabBarExample> with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
title: Text('AppBar Title'),
pinned: true,
expandedHeight: 200.0,
bottom: TabBar(
controller: _tabController,
tabs: <Widget>[
Tab(text: 'Tab 1'),
Tab(text: 'Tab 2'),
],
),
),
];
},
body: TabBarView(
controller: _tabController,
children: <Widget>[
ListView.builder(
itemCount: 100,
itemBuilder: (BuildContext context, int index) {
return ListTile(title: Text('Item $index'));
},
),
ListView.builder(
itemCount: 100,
itemBuilder: (BuildContext context, int index) {
return List
评论已关闭