- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我想在水平 PageView 中放置一个选项卡,并且能够滑出选项卡。在内容区域内,我可以从一个页面滑入选项卡,但不能从选项卡滑出到另一个页面。如果我在 TabBar 上滑动,那么我可以离开选项卡并转到相邻的页面。
有没有办法允许我从 TabView 内容区域滑动并将其移动到相邻的 PageView 页面?
这是我的测试代码:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
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> {
@override
Widget build(BuildContext context) {
return PageView(
children: <Widget>[
Scaffold(
appBar: AppBar(title: Text('Page 1'),),
body: Center(child: Text('hi'),),
),
DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
bottom: TabBar(
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
),
body: TabBarView(
children: [
Icon(Icons.directions_car),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
],
),
),
),
Scaffold(
appBar: AppBar(title: Text('Page 3'),),
body: Center(child: Text('bye'),),
),
],
);
}
}
最佳答案
好的,我相信我知道您在寻找什么。为此,我建议在您的小部件树中使用类似 NotificationListener
的东西来捕获 OverscrollNotification
并且您可以向左或向右滚动,具体取决于过度滚动的一侧(较少左边大于 0,右边大于 0)。
我让它的每一侧都呈线性(250 毫秒)动画,但您可以根据需要对其进行调整。
class Example extends StatefulWidget {
Example({Key key}) : super(key: key);
@override
_ExampleState createState() => _ExampleState();
}
class _ExampleState extends State<Example> with SingleTickerProviderStateMixin {
TabController _tabController;
final PageController _pageController = PageController();
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, length: 3);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Example'),
),
body: PageView(
controller: _pageController,
children: <Widget>[
Center(child: Text('Page 1')),
Column(
children: <Widget>[
TabPageSelector(controller: _tabController),
Text('Page 2'),
NotificationListener(
onNotification: (overscroll) {
if (overscroll is OverscrollNotification && overscroll.overscroll != 0 && overscroll.dragDetails != null) {
_pageController.animateToPage(overscroll.overscroll < 0 ? 0 : 2,
curve: Curves.ease, duration: Duration(milliseconds: 250));
}
return true;
},
child: Expanded(
child: TabBarView(
controller: _tabController,
children: <Widget>[
Center(child: Text('Tab 1')),
Center(child: Text('Tab 2')),
Center(child: Text('Tab 3')),
],
),
),
),
],
),
Center(child: Text('Page 3')),
],
),
);
}
}
关于flutter - 是否可以从 TabBarView 内容区域滑动到相邻的 PageView 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56907970/
我一直在尝试使用标签更改应用栏标题的许多解决方案,我解决了它,但现在有一个小问题;按下选项卡时,应用栏会随选项卡而变化,但不会随选项卡 View 而变化。在选项卡栏 View 上向左或向右滑动会更改选
我使用 TabBarView 并且我注意到一些非常奇怪的事情。我在所有选项卡的小部件中放置了一些打印消息,以便在滑动选项卡时获得反馈。我得到了这些结果: 从 0 -> 1:选项卡 1 调用,选项卡 3
这是我的布局结构 这是主界面 ListView( children: [ _buildCarousel(), _buildHomeTabBar(), ], ) 这是 HomeT
如何为未选中的标签添加下划线,如下所示: https://ibb.co/mfkzKp 在这里您可以看到未选中的选项卡为灰色,选中的选项卡为蓝色。 最佳答案 我在文档中没有找到任何关于如何自定义禁用指标
我需要在 Flutter 中实现如下布局。 当用户滚动时,我希望整个布局滚动(隐藏标题和标签栏)。但是,我不能将 TabBarView 嵌套在 ListView 中,因为 TabBarView 没有限
我在 SingleChildScrollView 中创建了 TabBar。问题是我想用我的整个应用程序在 TabBarView 中创建可滚动的内容,而不是仅在 TabBarView 中滚动内容。我尝试
我想在我的 flutter 页面中添加一些标签,但没有一个只有标签的页面。 简而言之,我有一些输入字段,在它们下面我想放置我的标签。 我不断收到此错误:TabBarView 没有 TabControl
我想构建一个 UI,其中我在屏幕顶部有一些固定的小部件(在所有选项卡上可见),然后在它们下面我想要一个 TabBarView(底部有选项卡栏),这是否可能而不使您的自己的标签小部件还是 TabBarV
我的 Flutter 应用有 3 个标签页。当应用程序加载时,我希望它加载所有 3 个页面,而不仅仅是它将显示的页面。我的问题是,当滑动到我的其他选项卡时,加载内容需要一秒钟,然后它会显示动画。为这种
想要在 flutter 中克隆 playstore 首页应用栏滚动功能。 Playstore Appbar我正在尝试在 SliverAppBar 底部属性下制作一个包含静态选项卡的屏幕。每当我单击任何
我有一个包含项目列表的 TabBarView,我为每个项目分配了一个 Navigator.push 方法。目前该方法会跳转到新页面。 我的问题是,是否可以导航到 TabBarView 主体内的新页面?
Flutter 的新手,不知道如何在我的 UI 上设置大小限制,以免溢出。尝试使用选项卡制作一些不同的 UI,我在选项卡栏上方有一些组件。基本上我想要这样的东西: ------------------
我想使用 TabBar 和 BottomNavigationBar 来控制相同的 TabBarView,其主体是自定义小部件 RankingTable 的列表(仅在演示中放置一个并使用文本小部件作为第
TabBar 小部件有一个 onTap() 回调,允许检测用户何时刚刚按下了一个选项卡。这很有用,我们可以准备新的 tabView 来显示一些动态数据。 TabBar 小部件还有一个拖动功能,允许更改
我的 tabBar 有一个 StatelessWidget 小部件,其中包含 2 个 statefulWidget。问题是,当单击管理器以查看我的所有选项卡时(默认情况下登陆我的第一个选项卡),tab
我用 DefaultTabController 实现了一个基本的 TabBar 和 TabBarView,见下面的代码。 class MyApp2 extends StatelessWidget {
我有下面的代码来让 TabBarView 与条子效果一起工作。问题是当用户滚动到末尾时我需要加载更多数据。但是每次向下滚动时,_handleScrolling 函数都不会被触发。我必须再次上下滚动才能
我的问题是我想要一个 TabBarView 在 SingleChildScrollView 但它给了我这个错误:RenderFlex child 有非零弹性,但传入的高度约束是无界的。 如果我删除 S
我正在开发一个 flutter 应用程序。我有一个有六个 child 的底部栏。其中两个是 TabBar 屏幕,但我对它们有疑问。每当我在 TabBar/TabBarView 中更改选定的选项卡并移动
Check video for more clearifacation gitlab link 我的代码 import 'package:flutter/material.dart'; import
我是一名优秀的程序员,十分优秀!