-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
sample code like this
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, length: 3);
}
@override
Widget build(BuildContext context) {
var sliverList = <Widget>[
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverToBoxAdapter(
child: Container(
color: randomColor(),
height: 200,
),
),
SliverPersistentHeader(
pinned: true,
delegate: _SliverPersistentHeaderDelegate(_tabController),
),
];
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('TEST'),
),
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return sliverList;
},
body: TabBarView(
controller: _tabController,
children: <Widget>[
CustomScrollView(
slivers: <Widget>[
SliverToBoxAdapter(
child: Container(
height: 200,
color: randomColor(),
),
),
SliverToBoxAdapter(
child: Container(
height: 400,
color: randomColor(),
),
),
SliverToBoxAdapter(
child: Container(
height: 300,
color: randomColor(),
),
),
SliverToBoxAdapter(
child: Container(
height: 400,
color: randomColor(),
),
),
SliverToBoxAdapter(
child: Container(
height: 200,
color: randomColor(),
),
),
],
),
Container(
height: 1400,
color: randomColor(),
),
Container(
height: 1400,
color: randomColor(),
),
],
),
),
);
}
}
class _SliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
final TabController tabController;
_SliverPersistentHeaderDelegate(this.tabController);
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
return TabBar(
controller: tabController,
labelColor: Colors.blue,
tabs: <Widget>[
Tab(
text: '111',
),
Tab(
text: '222',
),
Tab(
text: '333',
),
],
);
}
@override
double get maxExtent => TabBar(
tabs: <Widget>[],
).preferredSize.height;
@override
double get minExtent => TabBar(
tabs: <Widget>[],
).preferredSize.height;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
}
Color randomColor() {
List<MaterialColor> colors = [
Colors.red,
Colors.orange,
Colors.yellow,
Colors.green,
Colors.cyan,
Colors.blue,
Colors.purple,
];
return colors[Random.secure().nextInt(6)][Random.secure().nextInt(8) * 100 + 100];
}
flutter doctor
[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale zh-Hans-CN)
• Flutter version 1.17.3 at /Volumes/DATA/Library/Flutter/sdk
• Framework revision b041144f83 (10 days ago), 2020-06-04 09:26:11 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Volumes/DATA/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = /Volumes/DATA/Library/Android/sdk
• Java binary at: /Volumes/DATA/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[!] IntelliJ IDEA Community Edition (version 2020.1.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] VS Code (version 1.46.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.11.0
[✓] Connected device (1 available)
• GM1900 • 73b80a9b • android-arm64 • Android 10 (API 29)
! Doctor found issues in 2 categories.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team