步进器小部件中的垂直线
vertical line in Stepper widget
为什么待定文本旁边有一条竖线?
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
Navigator.pop(context, true);
return false;
},
child: Scaffold(
appBar: AppBar(title: (Text("NCR Update"))),
body: StreamBuilder<NCRTableData>(
stream: _ncrBloc.ncrStream,
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.active:
if (snapshot.hasData) {
return Stepper(
onStepTapped: (int index) {
setState(() {
_index = index;
});
},
currentStep: _index,
physics: ClampingScrollPhysics(),
controlsBuilder:
(BuildContext context, ControlsDetails controls) {
return Column(children: []);
},
steps: [
Step(
isActive: _index >= 0,
state: _index <= 0
? StepState.editing
: StepState.complete,
title: const Text(
'Part 1 ',
style: TextStyle(fontSize: 13),
),
content: Container(
alignment: Alignment.centerLeft,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
_showInfo(),
],
)
]))),
Step(
isActive: _index >= 1,
state: _index <= 1
? StepState.editing
: StepState.complete,
title: Text(
'Part 2',
style: TextStyle(fontSize: 13),
),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [Text("Pending...")],
)),
Step(
content: Text("efe"),
isActive: _index >= 2,
state: _index <= 2
? StepState.editing
: StepState.complete,
title: Text(
'Part 3',
style: TextStyle(fontSize: 13),
),
),
Step(
isActive: _index >= 3,
state: _index <= 3
? StepState.editing
: StepState.complete,
title: Text("Part 4"),
content: Text("Pending...")),
],
);
} else {
return Center(
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Icon(
Icons.format_list_bulleted,
size: 80,
color: Colors.orange,
),
SizedBox(
height: 20,
),
Text(
'No item',
style: TextStyle(fontSize: 18),
)
])));
}
case ConnectionState.waiting:
return Center(
child: Image.asset(
'assets/loading.gif',
width: 200.0,
height: 200.0,
));
default:
return Text("Error");
}
},
)));
}
在您的步进器中,在第 2 部分、第 3 部分和第 4 部分中,您忘记了用 Align 小部件包装内容,更新您的代码如下,它将按预期工作:
Step(
isActive: _index >= 1,
state: _index <= 1
? StepState.editing
: StepState.complete,
title: Text(
'Part 2',
style: TextStyle(fontSize: 13),
),
content: Align(
alignment: Alignment.centerLeft,
child: Text("Pending..."),
)),
Step(
isActive: _index >= 2,
state: _index <= 2
? StepState.editing
: StepState.complete,
title: Text(
'Part 3',
style: TextStyle(fontSize: 13),
),
content: Align(
alignment: Alignment.centerLeft,
child: Text("efe")
),
),
Step(
isActive: _index >= 3,
state: _index <= 3
? StepState.editing
: StepState.complete,
title: Text("Part 4"),
content: Align(
alignment: Alignment.centerLeft,
child: Text("Pending...")
)
),
为什么待定文本旁边有一条竖线?
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
Navigator.pop(context, true);
return false;
},
child: Scaffold(
appBar: AppBar(title: (Text("NCR Update"))),
body: StreamBuilder<NCRTableData>(
stream: _ncrBloc.ncrStream,
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.active:
if (snapshot.hasData) {
return Stepper(
onStepTapped: (int index) {
setState(() {
_index = index;
});
},
currentStep: _index,
physics: ClampingScrollPhysics(),
controlsBuilder:
(BuildContext context, ControlsDetails controls) {
return Column(children: []);
},
steps: [
Step(
isActive: _index >= 0,
state: _index <= 0
? StepState.editing
: StepState.complete,
title: const Text(
'Part 1 ',
style: TextStyle(fontSize: 13),
),
content: Container(
alignment: Alignment.centerLeft,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
_showInfo(),
],
)
]))),
Step(
isActive: _index >= 1,
state: _index <= 1
? StepState.editing
: StepState.complete,
title: Text(
'Part 2',
style: TextStyle(fontSize: 13),
),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [Text("Pending...")],
)),
Step(
content: Text("efe"),
isActive: _index >= 2,
state: _index <= 2
? StepState.editing
: StepState.complete,
title: Text(
'Part 3',
style: TextStyle(fontSize: 13),
),
),
Step(
isActive: _index >= 3,
state: _index <= 3
? StepState.editing
: StepState.complete,
title: Text("Part 4"),
content: Text("Pending...")),
],
);
} else {
return Center(
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Icon(
Icons.format_list_bulleted,
size: 80,
color: Colors.orange,
),
SizedBox(
height: 20,
),
Text(
'No item',
style: TextStyle(fontSize: 18),
)
])));
}
case ConnectionState.waiting:
return Center(
child: Image.asset(
'assets/loading.gif',
width: 200.0,
height: 200.0,
));
default:
return Text("Error");
}
},
)));
}
在您的步进器中,在第 2 部分、第 3 部分和第 4 部分中,您忘记了用 Align 小部件包装内容,更新您的代码如下,它将按预期工作:
Step(
isActive: _index >= 1,
state: _index <= 1
? StepState.editing
: StepState.complete,
title: Text(
'Part 2',
style: TextStyle(fontSize: 13),
),
content: Align(
alignment: Alignment.centerLeft,
child: Text("Pending..."),
)),
Step(
isActive: _index >= 2,
state: _index <= 2
? StepState.editing
: StepState.complete,
title: Text(
'Part 3',
style: TextStyle(fontSize: 13),
),
content: Align(
alignment: Alignment.centerLeft,
child: Text("efe")
),
),
Step(
isActive: _index >= 3,
state: _index <= 3
? StepState.editing
: StepState.complete,
title: Text("Part 4"),
content: Align(
alignment: Alignment.centerLeft,
child: Text("Pending...")
)
),