我正在关注本教程https://www.youtube.com/watch?v=izbkS2svuq4
并简要提及将 StepState 修改为 StepState.editing 以便您获得铅笔图标。
如何修改我所在步骤的 StepState,以便在我踏上/越过它时将状态更改为正在编辑(或完成)
class _SimpleWidgetState extends State<SimpleWidget> {
int _stepCounter = 0;
List<Step> steps = [
Step(
title: Text("Step One"),
content: Text("This is the first step"),
isActive: true
),
Step(
title: Text("Step Two"),
content: Text("This is the second step"),
isActive: true,
),
Step(
title: Text("Step Three"),
content: Text("This is the third step"),
isActive: true,
),
Step(
title: Text("Step Four"),
content: Text("This is the fourth step"),
isActive: true,
),
];
@override
Widget build(BuildContext context) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试显示来自步进器的单个值。
显示步进器在文本解释中显示双精度值。
例如,我将值 litreValue 设置为 Double,然后使用步进器可以选择一个值,例如 8,但我希望它在文本字段中仅显示为 8,而不是 8.000000。
我尝试过 Text("(NSString(format: "%.2f", litreValue))") 但出现错误。
有什么建议请。
import SwiftUI
struct ContentView: View {
@State private var litreValue : Double = 0.00
@State private var selection = 0
let mixRatio = ["10:1","15:1","20:1","25:1","30:1","35:1","40:1","45:1","50:1","55:1","60:1","65:1","70:1"]
var body: some View {
VStack{
ZStack{
RoundedRectangle(cornerRadius: /*@START_MENU_TOKEN@*/20/*@END_MENU_TOKEN@*/)
.foregroundColor(/*@START_MENU_TOKEN@*/.blue/*@END_MENU_TOKEN@*/)
.frame(width: 300.0, height: 200.0)
.shadow(radius: /*@START_MENU_TOKEN@*/10/*@END_MENU_TOKEN@*/)
VStack {
Image("Fuel-Icon2")
.resizable()
.frame(width: /*@START_MENU_TOKEN@*/100.0/*@END_MENU_TOKEN@*/, height: /*@START_MENU_TOKEN@*/100.0/*@END_MENU_TOKEN@*/)
Text("Fuel Mix")
.font(.largeTitle)
}
}
VStack {
Stepper(value: $litreValue, in: 1...200) {
Text("Litres")
.font(.title)
}.padding(.top, -30)
ZStack{ …Run Code Online (Sandbox Code Playgroud) 我使用android-material-stepper库进行步骤实现,但在这里我可以使用一个片段,它显示了 3 个步骤。
我需要不同步骤的不同片段,如何使用?
我有不同的观点,比如片段 1 有日历,片段 2 有按钮,片段 3 有输入框。我想分别为每 3 个步骤使用所有 3 个片段。
我按照该 GitHub 页面中所示进行了实施,并且他们在 3 个步骤中仅使用了 1 个片段。有没有办法使用3个片段?如果不是,我如何区分同一片段中每个步骤的 3 个功能?
请帮忙!
我正在尝试在 Stepper 下方制作一个按钮。问题是,如果我将它包装在 Column 或 ListView 中,则在 Stepper 中滚动不起作用。我试图用 NestedScrollView 将它们包装起来,滚动工作正常,但问题是在 Stepper 上方发布的按钮。代码中有两个 _MyHomePageState 示例,第一个是 ListView,第二个是 NestedView,两者都不适合我。如何在其下实现带有 Button 的 Stepper?
这是我想要的 在此处输入图像描述
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
// 1 case …Run Code Online (Sandbox Code Playgroud)