【发布时间】:2018-03-27 17:57:21
【问题描述】:
我有 ListView,其中包含 - 1. 横幅图片 2. 带有一些文本的容器 3. 包含更多文本的容器 4. 容器由步进器组成。
当我在点击步进器区域时尝试滚动时,我无法滚动。甚至步进器的最后一步也会出现在屏幕之外。
添加代码 -
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new HomePage(),
);
}
}
class HomePage extends StatelessWidget{
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new ListView(
children: <Widget>[
new MyContents(),
new MyContents(),
new MyContents(),
new MyContents(),
new SimpleWidget(),
],
),
);
}
}
class MyContents extends StatelessWidget{
@override
Widget build(BuildContext context) {
return new Container(
padding: new EdgeInsets.all(40.0),
child: new Card(
child: new Column(
children: <Widget>[
new Text(
"Cards Content Cards ContentCards Content Cards Content Cards ContentCards Content Cards Content Cards Content "
),
new Text(
"Cards Content Cards ContentCards Content Cards Content Cards ContentCards Content Cards Content Cards Content "
),
new Text(
"Cards Content Cards ContentCards Content Cards Content Cards ContentCards Content Cards Content Cards Content "
),
new Text(
"Cards Content Cards ContentCards Content Cards Content Cards ContentCards Content Cards Content Cards Content "
)
],
),
),
);
}
}
class SimpleWidget extends StatefulWidget {
@override
SimpleWidgetState createState() => new SimpleWidgetState();
}
class SimpleWidgetState extends State<SimpleWidget> {
int stepCounter = 0;
List<Step> steps = [
new Step(
title:new Text("Step One"),
content: new Text("This is the first step"),
isActive: true,
),
new Step(
title:new Text("Step Two"),
content: new Text("This is the second step"),
isActive: true,
),
new Step(
title:new Text("Step Three"),
content: new Wrap(
spacing: 8.0, // gap between adjacent chips
runSpacing: 4.0, // gap between lines
direction: Axis.horizontal, // main axis (rows or columns)
children: <Widget>[
new Chip(
label: new Text('Chips11')
),new Chip(
label: new Text('Chips12')
),new Chip(
label: new Text('Chips13')
),new Chip(
label: new Text('Chips14')
),new Chip(
label: new Text('Chips15')
),new Chip(
label: new Text('Chips16')
)
],
),
state: StepState.editing,
isActive: true,
),
new Step(
title: new Text("Step Four"),
content: new Text("This is the fourth step"),
isActive: true,
),
];
@override
Widget build(BuildContext context) {
return new Container(
child: new Stepper(
currentStep: this.stepCounter,
steps: steps,
type: StepperType.vertical,
onStepTapped: (step) {
setState(() {
stepCounter = step;
});
},
onStepCancel: () {
setState(() {
stepCounter > 0 ? stepCounter -= 1 : stepCounter = 0;
});
},
onStepContinue: () {
setState(() {
stepCounter < steps.length - 1 ? stepCounter += 1 : stepCounter = 0;
});
},
),
);
}
}
尝试滚动点击步进器区域。它不工作。
【问题讨论】:
-
您能提供一些代码示例吗?
-
已编辑帖子,查看!