我目前正在开发一个应用。 为此,我使用了颤动步进器,但是我遇到的问题是内部内容不可滚动,我已经尝试了几种可能性,但未成功。 我已插入图片+代码 我希望你能帮助我。
图片:
body: Container(
child: Stepper(
physics: BouncingScrollPhysics(),
steps: stepsStammdaten(),
currentStep: currentStep,
onStepContinue: next,
onStepTapped: (step) => goTo(step),
onStepCancel: cancel,
),
Step(
state: StepState.indexed,
isActive: true,
title: const Text('Rejkla'),
content: ListView.builder(
shrinkWrap: true,
itemCount: this.index,
itemBuilder: (context, index) => this._buildRow(index),
)
),´´´
The method buildRow() contains a ListView
return ListView(
physics: const AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
children: <Widget>[
// Here are some text inputs
]);
答案 0 :(得分:0)
此code
最适合我。
通过替换下面的代码
physics: BouncingScrollPhysics(),
与此
physics : ClampingScrollPhysics(),
它应该能够完美滚动。
答案 1 :(得分:0)
感谢你们Mukul和CodOg。我也陷入了同样的问题,并且阅读了您的谈话,这对我解决问题大有帮助。我尝试了这个。而这个正在工作。
import 'package:flutter/material.dart';
class AddMember extends StatefulWidget {
@override
_AddMemberState createState() => _AddMemberState();
}
class _AddMemberState extends State<AddMember> {
int _currentStep = 0;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('ADD MEMBERS'),
backgroundColor: Colors.orange,
),
body: Theme(
data: ThemeData(primaryColor: Colors.orange),
child: Form(
child: new Stepper(
physics: ClampingScrollPhysics(),
steps: _myStep(),
currentStep: this._currentStep,
onStepTapped: (step) {
setState(() {
this._currentStep = step;
});
},
onStepContinue: () {
setState(() {
if (this._currentStep < this._myStep().length - 1) {
this._currentStep = this._currentStep + 1;
} else {
print('Completed, Check the Filed');
}
});
},
onStepCancel: () {
setState(() {
if (this._currentStep > 0) {
this._currentStep = this._currentStep - 1;
} else {
this._currentStep = 0;
}
});
},
),
),
),
);
}
List<Step> _myStep() {
List<Step> _steps = [
Step(
title: Text('Personal Details'),
content: new Container(
height: 500,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
new TextFormField(
autofocus: true,
decoration: InputDecoration(
hintText: "First Name",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(
color: Colors.orange,
style: BorderStyle.solid,
)),
),
),
new TextFormField(
autofocus: true,
decoration: InputDecoration(
hintText: "First Name",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(
color: Colors.orange,
style: BorderStyle.solid,
)),
),
),
new TextFormField(
autofocus: true,
decoration: InputDecoration(
hintText: "First Name",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(
color: Colors.orange,
style: BorderStyle.solid,
)),
),
),
new TextFormField(
autofocus: true,
decoration: InputDecoration(
hintText: "First Name",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(
color: Colors.orange,
style: BorderStyle.solid,
)),
),
),
],
)
),
),
isActive: _currentStep >= 0,
),
Step(
title: Text('Residence Details'),
content: Form(child: TextField()),
isActive: _currentStep >= 1,
),
Step(
title: Text('Office Details'),
content: Form(child: TextField()),
isActive: _currentStep >= 2,
),
Step(
title: Text('Native Details'),
content: Form(child: TextField()),
isActive: _currentStep >= 3,
),
Step(
title: Text('Others Details'),
content: Form(child: TextField()),
isActive: _currentStep >= 4,
),
];
return _steps;
}
}