mat-stepper当我们从一个步骤切换到另一个步骤时,有没有办法禁用Angular材质控件的动画?
在屏幕截图中,我想让 next 和 back 按钮位于屏幕底部。
步进器有一个参数,controlsBuilder允许您构建控件的布局。如果它只是一个简单的行,它就放在内容的正下方。
显然,Stepper 是一个灵活的包装器。我不确定这意味着什么。我认为这意味着 Stepper 被认为是一个 flex 对象,因为它包含一个可滚动区域(用于内容)。阅读文档后,如果我理解正确,它说我不能在 mainAxis 中使用具有最大大小的anExpanded或 a Column,因为步进器本质上是一个可滚动区域,这意味着其中的任何 RenderBox 都具有无限约束。
那么,有哪些方法可以将控件构建器推到底呢?
Widget _createEventControlBuilder(BuildContext context, {VoidCallback onStepContinue, VoidCallback onStepCancel}) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FlatButton(
onPressed: onStepCancel,
child: const Text('BACK'),
),
FlatButton(
onPressed: onStepContinue,
child: const Text('NEXT'),
),
]
);
}
Run Code Online (Sandbox Code Playgroud)
我确实尝试将上面的行包装在 LayoutBuilder 以及使用 SizedBox 的另一次尝试中,将高度设置为MediaQuery.of(context).size.height;. 它确实将它推到了底部(不像我喜欢的那么多),但问题是现在控件下方有空间,导致屏幕向下滚动到空白空间。
完整代码:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Create an Event"),
), …Run Code Online (Sandbox Code Playgroud) 我在 Stepper 的每个步骤中都有多个表单,表单在外部文件中,因为在我的应用程序中,每个步骤都可以包含一个不同的表单。我希望当用户单击“继续”时,表单将被验证,并且在错误情况下用户将收到警告。我尝试使用 Inherited Widget 但它给了我一个“getter null”。下面的代码:包含步骤的屏幕
import 'package:flutter/material.dart';
import 'package:pberrycoffeemaker/widgets/function_appbar.dart';
import 'package:pberrycoffeemaker/widgets/inputs_0.dart';
import 'package:pberrycoffeemaker/widgets/stepper_banner.dart';
class FunctionScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
int indexStep = 0;
double bottomHeight = (MediaQuery.of(context).size.height * 40) / 100;
double cardHeight = (MediaQuery.of(context).size.height * 60) / 100;
double cardWidth = (MediaQuery.of(context).size.width * 85) / 100;
FirstTypeInput firstTypeOfInput = FirstTypeInput();
GlobalKey<FormState> key = new GlobalKey<FormState>();
return Scaffold(
body: Stack(
children: <Widget>[
AppbarBack(
height: bottomHeight,
),
Align(
alignment: Alignment(0.0, .65),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(15.0)), …Run Code Online (Sandbox Code Playgroud) 有没有办法可以在步进器组件的各个步骤之间共享数据?
例如,在下面的代码中,我希望以 的形式填写的数据app-step1在组件中可用app-step2。
<mat-horizontal-stepper [linear]="true" #stepper="matHorizontalStepper" >
<mat-step [stepControl]="zerpFormGroup" >
<ng-template matStepLabel>Step I</ng-template>
<app-step1 [stepper]="stepper"></app-step1>
</mat-step>
<mat-step [stepControl]="firstFormGroup" >
<ng-template matStepLabel ">Step II</ng-template><br>
<app-step2 [stepper]="stepper"></app-step2>
</mat-step>
Run Code Online (Sandbox Code Playgroud)
我需要一个步进器来显示某事物的当前状态(以步骤为单位)。因此我想一次显示所有状态的内容。我去掉了默认的继续和取消按钮,但它只显示第一步的内容。
这是我的代码:
body: Center(
child: new Stepper(
steps: my_steps,
controlsBuilder: (BuildContext context,
{VoidCallback onStepContinue, VoidCallback onStepCancel}) {
return Row(
children: <Widget>[
Container(
child: null,
),
Container(
child: null,
),
],
);
},
),
),
Run Code Online (Sandbox Code Playgroud)
这些是我的步骤:
List<Step> my_steps = [
new Step(
title: new Text("Step 1"),
content: new Text("Hello 1!")),
new Step(
title: new Text("Step 2"),
content: new Text("Hello 2!")
),
new Step(
title: new Text("Step 3"),
content: new Text("Hello World!"),
)
];
Run Code Online (Sandbox Code Playgroud)
这里第一步只显示“Hello 1”。其余内容为空。
任何人?
我正在尝试实现一个带有数字输入的 TextField 以及 Stepper 来控制数量。在文本字段中输入数字后,步进器将失去更改数字的能力。我很确定绑定值有一个技巧,但无法弄清楚到底是什么。
struct TestView: View {
@State var quantity: Int = 0
var body: some View {
HStack {
TextField("", value: $quantity, formatter: NumberFormatter())
Stepper("", onIncrement: {
self.quantity += 1
}, onDecrement: {
self.quantity -= 1
})
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用步进器小部件来从用户那里收集信息并对其进行验证,我需要在每一步调用一个 API,因此在每个继续按钮的步骤中验证每个字段......我正在使用表单状态和表单小部件但问题是它在步进器的所有步骤中验证整个字段......我如何仅验证步进器中的单个步骤?我浏览了 stepper.dart 中的 Stepper 和 State 类中的文档,但那里没有支持功能
以下是代码
class SubmitPayment extends StatefulWidget {
SubmitPayment({Key key, this.identifier, this.amount, this.onResendPressed})
: super(key: key);
final String identifier;
final String amount;
final VoidCallback onResendPressed;
@override
State<StatefulWidget> createState() {
return _SubmitPaymentState();
}
}
class _SubmitPaymentState extends State<SubmitPayment> {
final GlobalKey<FormState> _formKeyOtp = GlobalKey<FormState>();
final FocusNode _otpFocusNode = FocusNode();
final TextEditingController _otpController = TextEditingController();
bool _isOTPRequired = false;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Form(
key: _formKeyOtp,
child: Column(children: …Run Code Online (Sandbox Code Playgroud) 有没有办法在不创建自定义 Stepper 的情况下更改 Steps 的颜色?当前步骤是蓝色的。
https://docs.flutter.io/flutter/material/Stepper-class.html
https://docs.flutter.io/flutter/material/Step-class.html