当我尝试在我的应用程序中创建一个像顶部栏的Android状态栏时,我使用手势检测器,但我不知道如何继续它。如何在上方隐藏容器并在如下滑动时获取容器:
在滑动结束并测量滑动距离后如何执行某些操作。顶部栏应该安静下来,而不是留在中间。我如何设置动画以使其与现在的方式类似。我尝试了onVerticalDrag
等,但我不知道如何做到这一点。
Flutter Slivers可以为您做到这一点。
检查以下代码:
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(
home: Scaffold(
body:NestedScrollView(
headerSliverBuilder: (BuildContext context, bool _) {
return <Widget>[
SliverAppBar(
expandedHeight: 200.0,
floating: true,
pinned: true,
snap: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text("Collapsing Toolbar",
style: TextStyle(
color: Colors.white,
fontSize: 16.0,
),
),
),
),
];
},
body: Center(
child: Text("My Fancy Text"),
),
),
),
);
}
}