【发布时间】:2021-08-13 23:21:02
【问题描述】:
我有以下小部件,它垂直显示一些食谱的图片列表,当滑动到每个食谱的右侧页面时,它会转到其描述页面。这里的问题是,当我转到DescriptionScreen 时,我可以向下滚动并转到其他收件人的RecipeScreen。我想阻止它,仅当用户在RecipeScreen 上时允许垂直滚动,否则如果他在DescriptionScreen 上,则能够向左滑动并继续滚动。怎么可能做到这一点?
Widget build(BuildContext context) {
return Scaffold(
extendBody: true,
extendBodyBehindAppBar: true,
body: Column(
children: [
Expanded(
child: PageView.builder(
controller: verticalPageController,
scrollDirection: Axis.vertical,
itemCount: recipes.length,
allowImplicitScrolling: true,
itemBuilder: (BuildContext context, int index) {
return PageView(
controller: pageControllers[index],
children: [
RecipeScreen(
recipe: recipes[index],
onRecipeDelete: onRecipeDelete,
),
),
DescriptionScreen(
recipeId: recipes[index].id,
onRecipeSave: onRecipeSave,
),
],
);
},
),
),
SafeArea(
top: false,
child: Container(height: 0),
),
],
),
bottomNavigationBar: BottomBar(
page: currentPage,
),
);
}
【问题讨论】:
标签: flutter