我用 Stepper 小部件创建了一个分 3 部分的长表单。而验证第一个字段在屏幕之外。所以我必须滚动到顶部,然后我才能看到显示错误的文本字段。
屏幕内的其他文本字段很好。但不适用于屏幕外的字段。
实际上,一个错误是什么?下面是build()方法。
return WillPopScope(
child: Scaffold(
appBar: AppBar(
title: Text('Details'),
),
body: Stepper(
controlsBuilder: (context, {onStepCancel, onStepContinue}) {
return stepperFormButtons(onStepContinue, onStepCancel);
},
type: StepperType.horizontal,
steps: getSteps(size: size),
currentStep: currentStep,
onStepContinue: () {
stepContinue();
},
onStepCancel: () {
if (currentStep != 0) {
setState(() {
currentStep = currentStep - 1;
});
}
},
),
),
);
Step step1() {
return Step(
isActive: currentStep > 0,
title: Text(
'Details',
style: TextStyle(fontSize: 12),
),
content: SingleChildScrollView(
child: Form(
key: _formKeys[0],
child: Column(
children: [
NameOfTheShop(
focus: _ShopNameFocus,
nextFocus: _phoneFocus,
controller: _ShopNameController,
),
mobileNumberVerify(context),
whatsAppAlternate == false
? WhatsAppNumber(
focusNode: _whatsAppNumberFocus,
nextFocus: _emailFocus,
controller: _whatsAppNumberController,
)
: const SizedBox.shrink(),
EmailWidget(
focusNode: _emailFocus,
nextFocus: _nameOfTheShop,
controller: _emailController,
validatorMessage: "Email Cant be empty",
),
],
),
),
),
state: currentStep > 0 ? StepState.complete : StepState.indexed,
);
}