如何使列在颤振网中可滚动?



父组件是列,列包含以下子元素:

堆栈
  • 容器(孩子:行)
  • ROW(CHILDREN: [gestredetector (child:Container), gestredetector (child:Container)]
  • LISTVIEW BUILDER

用expanded包装这个列,然后用singlechildScrollView。结果是错误!!

该怎么办??

SinglechildScrollView包裹Column,对于ListView.builder需要设置:

physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,

在您的示例中,小部件树看起来像这样(最小可复制示例)

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SingleChildScrollView',
home: Scaffold(
appBar: AppBar(
title: Text('SingleChildScrollView Example'),
),
body: SingleChildScrollView(
child: Column(
children: [
Stack(
children: [
Container(
width: 50,
height: 50,
color: Colors.cyan,
),
],
),
Container(
child: Row(
children: [
GestureDetector(
child: Container(
width: 50,
height: 50,
color: Colors.green,
),
),
GestureDetector(
child: Container(
width: 50,
height: 50,
color: Colors.blue,
),
),
],
),
),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 60,
itemBuilder: (context, index) => Text('Item # $index'),
)
],
),
)),
);
}
}

滚动

最新更新