gpt4 book ai didi

flutter - 水平 ListView 不在网络上滚动,而是在移动设备上滚动

转载 作者:行者123 更新时间:2023-12-04 14:35:12 26 4
gpt4 key购买 nike

在 flutter 2.5 更新之后, ListView 仅在移动平台上滚动。当我在网络上打开它时它不会滚动。它在以前的版本中运行良好。我尝试了滚动物理,但没有奏效。你建议我做什么?对不起,我的英语不好。


return SizedBox(
height: 400,
child: ListView.builder(
physics: ClampingScrollPhysics(),
scrollDirection: Axis.horizontal,
// ignore: unnecessary_null_comparison
itemCount: items == null ? 0 : items.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
LoginForm();
},
child: Container(
margin:
EdgeInsets.symmetric(horizontal: 20, vertical: 6),
child: SizedBox(
width: 400,
height: 50,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(20.0)),
boxShadow: [
BoxShadow(
color: fromCssColor(
items[index].color.toString()),
// color: Colors.black38,
offset: Offset(2.0, 2.0),
blurRadius: 5.0,
spreadRadius: 1.0)
]),
),
ClipRRect(
borderRadius:
BorderRadius.all(Radius.circular(20.0)),
child: Image.asset(
items[index].image.toString(),
fit: BoxFit.cover,
),
),
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(20.0)),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
Colors.black45
]))
),
],
),
),

最佳答案

Flutter 2.5 总结

ScrollBehaviors now allow or disallow drag scrolling from specifiedPointerDeviceKinds. ScrollBehavior.dragDevices, by default, allowsscrolling widgets to be dragged by all PointerDeviceKinds except forPointerDeviceKind.mouse.

// Set ScrollBehavior for an entire application.
MaterialApp(
scrollBehavior: MyCustomScrollBehavior(),
// ...
);
class MyCustomScrollBehavior extends MaterialScrollBehavior {
// Override behavior methods and getters like dragDevices
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
};
}
引用: Documentation

关于flutter - 水平 ListView 不在网络上滚动,而是在移动设备上滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69154468/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com