我需要在文本区域中显示列表的多个索引
I need multiple indexes of a list displayed in a text area
我正在尝试填写产品和其他相关项目的列表,但我正在努力弄清楚如何让他们将每个产品打印到自己的区域。我可以通过选择其特定索引来打印单个项目,如下面的代码所示。
children: [
AutoSizeText(
portProductName[],
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
24,
fontWeight:
FontWeight
.w600,
),
),
],
我正在使用列表生成器制作我的列表。
这是循环查找端口产品名称的代码。
var ports = deviceList.ports;
List portProductName = [];
(ports).forEach((e) {
portProductName.add(e.productName);
});
同样,如果我指定索引,例如 0、1 等,我可以让产品显示,但每个实例都将包含相同的产品名称。我需要整个索引,但是我不能简单地写下索引这个词,而且我不知道如何让索引中的所有项目都显示出来。请帮忙,我是 dart/flutter 的新手,正在努力寻找解决此问题的正确语法。
我正在使用 Listview Builder 创建我的产品列表。如下面的代码以及提供的图像所示。
ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: deviceList.ports.length,
itemBuilder: (context, position)
根据要求,这里是 deviceList 变量。
Widget build(BuildContext context) {
DevicesModel deviceList = Get.find<DeviceController>.
().deviceList[deviceId];
根据要求,这里是上下文代码。
@override
Widget build(BuildContext context) {
DevicesModel deviceList = Get.find<DeviceController>().deviceList[deviceId];
print("device index is " + deviceId.toString());
print("device id is " + deviceList.deviceId);
// print(deviceList.ports.length);
var ports = deviceList.ports;
List portProductName = [];
(ports).forEach((e) {
portProductName.add(e.productName);
});
getSignalColor() {
if (deviceList.signalQualityClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getTempColor() {
if (deviceList.temperatureClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.temperatureClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.temperatureClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getStatusColor() {
if (deviceList.statusClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getSurgeStatus() {
if (deviceList.surgeProtection.toString() == "1") {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getPortInfo() {
var ports = deviceList.ports;
var portList = [];
(ports).forEach((e) {
portList.add(e.productName);
});
return portList;
}
return Scaffold(
// key: scaffoldKey,
backgroundColor: Colors.white,
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
IconButton(
hoverColor: Colors.transparent,
iconSize: 40,
icon: Icon(
Icons.keyboard_return_sharp,
color: Colors.black,
size: 30,
),
onPressed: () {
Navigator.pop(context);
},
),
Expanded(
child: Align(
alignment: AlignmentDirectional(-.14, 0),
child: Text(
deviceList.publicId! + ' ' + deviceList.label,
textAlign: TextAlign.center,
style:
FlutterFlowTheme.of(context).bodyText1.override(
fontFamily: 'Heebo',
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 20, 0),
child: Icon(
Icons.signal_cellular_alt_sharp,
color: getSignalColor(),
size: 24,
),
),
],
),
),
Divider(
height: 10,
thickness: 2,
color: Colors.black,
),
Container(
width: MediaQuery.of(context).size.width,
height: 514,
decoration: BoxDecoration(
color: Colors.white,
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Expanded(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0),
child: Expanded(
child: SingleChildScrollView(
child: Container(
height: 514,
child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: deviceList.ports.length,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
print('test');
},
child: Container(
margin: EdgeInsets.only(bottom: 10),
child: Container(
width: 100,
height: 131,
decoration: BoxDecoration(
color: Color(0xFFEDEDED),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
AutoSizeText(
portProductName[0],
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
24,
fontWeight:
FontWeight
.w600,
),
),
],
),
),
Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.start,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Order: 3000 G',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize: 18,
fontWeight:
FontWeight
.w500,
),
),
],
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 0, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
'Port 1',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceAround,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Remaining: 700 G',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
Text(
'Capacity: 1000 G',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 10),
child: LinearPercentIndicator(
percent: 0.75,
width:
MediaQuery.of(context)
.size
.width *
0.89,
lineHeight: 30,
animation: true,
progressColor:
FlutterFlowTheme
.of(context)
.primaryColor,
backgroundColor:
FlutterFlowTheme.of(
context)
.background,
center: Text(
'75%',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
color:
Colors.black,
),
),
barRadius:
Radius.circular(8)),
),
],
),
),
));
// return Text('success');
// return _buildPageItem(position, devices.deviceList[position]);
}),
),
))),
),
),
),
@override
Widget build(BuildContext context) {
DevicesModel deviceList = Get.find<DeviceController>().deviceList[deviceId];
print("device index is " + deviceId.toString());
print("device id is " + deviceList.deviceId);
// print(deviceList.ports.length);
var ports = deviceList.ports;
List portProductName = [];
(ports).forEach((e) {
portProductName.add(e.productName);
});
getSignalColor() {
if (deviceList.signalQualityClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getTempColor() {
if (deviceList.temperatureClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.temperatureClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.temperatureClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getStatusColor() {
if (deviceList.statusClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getSurgeStatus() {
if (deviceList.surgeProtection.toString() == "1") {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getPortInfo() {
var ports = deviceList.ports;
var portList = [];
(ports).forEach((e) {
portList.add(e.productName);
});
return portList;
}
return Scaffold(
// key: scaffoldKey,
backgroundColor: Colors.white,
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
IconButton(
hoverColor: Colors.transparent,
iconSize: 40,
icon: Icon(
Icons.keyboard_return_sharp,
color: Colors.black,
size: 30,
),
onPressed: () {
Navigator.pop(context);
},
),
Expanded(
child: Align(
alignment: AlignmentDirectional(-.14, 0),
child: Text(
deviceList.publicId! + ' ' + deviceList.label,
textAlign: TextAlign.center,
style:
FlutterFlowTheme.of(context).bodyText1.override(
fontFamily: 'Heebo',
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 20, 0),
child: Icon(
Icons.signal_cellular_alt_sharp,
color: getSignalColor(),
size: 24,
),
),
],
),
),
Divider(
height: 10,
thickness: 2,
color: Colors.black,
),
Container(
width: MediaQuery.of(context).size.width,
height: 514,
decoration: BoxDecoration(
color: Colors.white,
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Expanded(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0),
child: Expanded(
child: SingleChildScrollView(
child: Container(
height: 514,
child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: deviceList.ports.length,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
print('test');
},
child: Container(
margin: EdgeInsets.only(bottom: 10),
child: Container(
width: 100,
height: 131,
decoration: BoxDecoration(
color: Color(0xFFEDEDED),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
AutoSizeText(
deviceList.ports[position].productName,
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
24,
fontWeight:
FontWeight
.w600,
),
),
],
),
),
Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.start,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Order:${deviceList.ports[position].order}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize: 18,
fontWeight:
FontWeight
.w500,
),
),
],
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 0, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
'Port ${deviceList.ports[position].portNumber}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceAround,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Remaining: ${deviceList.ports[position].remaining}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
Text(
'Capacity: ${deviceList.ports[position].capacity}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 10),
child: LinearPercentIndicator(
percent: 0.75,
width:
MediaQuery.of(context)
.size
.width *
0.89,
lineHeight: 30,
animation: true,
progressColor:
FlutterFlowTheme
.of(context)
.primaryColor,
backgroundColor:
FlutterFlowTheme.of(
context)
.background,
center: Text(
'75%',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
color:
Colors.black,
),
),
barRadius:
Radius.circular(8)),
),
],
),
),
));
// return Text('success');
// return _buildPageItem(position, devices.deviceList[position]);
}),
),
))),
),
),
),
如果这些代码仍然不适合您,请与我联系。
rasityilmaz@yaani.com
我正在尝试填写产品和其他相关项目的列表,但我正在努力弄清楚如何让他们将每个产品打印到自己的区域。我可以通过选择其特定索引来打印单个项目,如下面的代码所示。
children: [
AutoSizeText(
portProductName[],
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
24,
fontWeight:
FontWeight
.w600,
),
),
],
我正在使用列表生成器制作我的列表。
这是循环查找端口产品名称的代码。
var ports = deviceList.ports;
List portProductName = [];
(ports).forEach((e) {
portProductName.add(e.productName);
});
同样,如果我指定索引,例如 0、1 等,我可以让产品显示,但每个实例都将包含相同的产品名称。我需要整个索引,但是我不能简单地写下索引这个词,而且我不知道如何让索引中的所有项目都显示出来。请帮忙,我是 dart/flutter 的新手,正在努力寻找解决此问题的正确语法。
我正在使用 Listview Builder 创建我的产品列表。如下面的代码以及提供的图像所示。
ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: deviceList.ports.length,
itemBuilder: (context, position)
根据要求,这里是 deviceList 变量。
Widget build(BuildContext context) {
DevicesModel deviceList = Get.find<DeviceController>.
().deviceList[deviceId];
根据要求,这里是上下文代码。
@override
Widget build(BuildContext context) {
DevicesModel deviceList = Get.find<DeviceController>().deviceList[deviceId];
print("device index is " + deviceId.toString());
print("device id is " + deviceList.deviceId);
// print(deviceList.ports.length);
var ports = deviceList.ports;
List portProductName = [];
(ports).forEach((e) {
portProductName.add(e.productName);
});
getSignalColor() {
if (deviceList.signalQualityClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getTempColor() {
if (deviceList.temperatureClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.temperatureClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.temperatureClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getStatusColor() {
if (deviceList.statusClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getSurgeStatus() {
if (deviceList.surgeProtection.toString() == "1") {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getPortInfo() {
var ports = deviceList.ports;
var portList = [];
(ports).forEach((e) {
portList.add(e.productName);
});
return portList;
}
return Scaffold(
// key: scaffoldKey,
backgroundColor: Colors.white,
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
IconButton(
hoverColor: Colors.transparent,
iconSize: 40,
icon: Icon(
Icons.keyboard_return_sharp,
color: Colors.black,
size: 30,
),
onPressed: () {
Navigator.pop(context);
},
),
Expanded(
child: Align(
alignment: AlignmentDirectional(-.14, 0),
child: Text(
deviceList.publicId! + ' ' + deviceList.label,
textAlign: TextAlign.center,
style:
FlutterFlowTheme.of(context).bodyText1.override(
fontFamily: 'Heebo',
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 20, 0),
child: Icon(
Icons.signal_cellular_alt_sharp,
color: getSignalColor(),
size: 24,
),
),
],
),
),
Divider(
height: 10,
thickness: 2,
color: Colors.black,
),
Container(
width: MediaQuery.of(context).size.width,
height: 514,
decoration: BoxDecoration(
color: Colors.white,
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Expanded(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0),
child: Expanded(
child: SingleChildScrollView(
child: Container(
height: 514,
child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: deviceList.ports.length,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
print('test');
},
child: Container(
margin: EdgeInsets.only(bottom: 10),
child: Container(
width: 100,
height: 131,
decoration: BoxDecoration(
color: Color(0xFFEDEDED),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
AutoSizeText(
portProductName[0],
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
24,
fontWeight:
FontWeight
.w600,
),
),
],
),
),
Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.start,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Order: 3000 G',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize: 18,
fontWeight:
FontWeight
.w500,
),
),
],
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 0, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
'Port 1',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceAround,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Remaining: 700 G',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
Text(
'Capacity: 1000 G',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 10),
child: LinearPercentIndicator(
percent: 0.75,
width:
MediaQuery.of(context)
.size
.width *
0.89,
lineHeight: 30,
animation: true,
progressColor:
FlutterFlowTheme
.of(context)
.primaryColor,
backgroundColor:
FlutterFlowTheme.of(
context)
.background,
center: Text(
'75%',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
color:
Colors.black,
),
),
barRadius:
Radius.circular(8)),
),
],
),
),
));
// return Text('success');
// return _buildPageItem(position, devices.deviceList[position]);
}),
),
))),
),
),
),
@override
Widget build(BuildContext context) {
DevicesModel deviceList = Get.find<DeviceController>().deviceList[deviceId];
print("device index is " + deviceId.toString());
print("device id is " + deviceList.deviceId);
// print(deviceList.ports.length);
var ports = deviceList.ports;
List portProductName = [];
(ports).forEach((e) {
portProductName.add(e.productName);
});
getSignalColor() {
if (deviceList.signalQualityClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getTempColor() {
if (deviceList.temperatureClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.temperatureClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.temperatureClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getStatusColor() {
if (deviceList.statusClass == 'yellow') {
Color color = Colors.yellow;
return color;
} else if (deviceList.signalQualityClass == 'red') {
Color color = Colors.red;
return color;
} else if (deviceList.signalQualityClass == 'green') {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getSurgeStatus() {
if (deviceList.surgeProtection.toString() == "1") {
Color color = Colors.green;
return color;
} else {
Color color = Colors.black26;
return color;
}
}
getPortInfo() {
var ports = deviceList.ports;
var portList = [];
(ports).forEach((e) {
portList.add(e.productName);
});
return portList;
}
return Scaffold(
// key: scaffoldKey,
backgroundColor: Colors.white,
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
IconButton(
hoverColor: Colors.transparent,
iconSize: 40,
icon: Icon(
Icons.keyboard_return_sharp,
color: Colors.black,
size: 30,
),
onPressed: () {
Navigator.pop(context);
},
),
Expanded(
child: Align(
alignment: AlignmentDirectional(-.14, 0),
child: Text(
deviceList.publicId! + ' ' + deviceList.label,
textAlign: TextAlign.center,
style:
FlutterFlowTheme.of(context).bodyText1.override(
fontFamily: 'Heebo',
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 20, 0),
child: Icon(
Icons.signal_cellular_alt_sharp,
color: getSignalColor(),
size: 24,
),
),
],
),
),
Divider(
height: 10,
thickness: 2,
color: Colors.black,
),
Container(
width: MediaQuery.of(context).size.width,
height: 514,
decoration: BoxDecoration(
color: Colors.white,
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Expanded(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0),
child: Expanded(
child: SingleChildScrollView(
child: Container(
height: 514,
child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: deviceList.ports.length,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
print('test');
},
child: Container(
margin: EdgeInsets.only(bottom: 10),
child: Container(
width: 100,
height: 131,
decoration: BoxDecoration(
color: Color(0xFFEDEDED),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
AutoSizeText(
deviceList.ports[position].productName,
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
24,
fontWeight:
FontWeight
.w600,
),
),
],
),
),
Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.start,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Order:${deviceList.ports[position].order}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize: 18,
fontWeight:
FontWeight
.w500,
),
),
],
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 0, 10, 0),
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.end,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
'Port ${deviceList.ports[position].portNumber}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
Expanded(
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceAround,
crossAxisAlignment:
CrossAxisAlignment
.end,
children: [
Text(
'Remaining: ${deviceList.ports[position].remaining}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
Text(
'Capacity: ${deviceList.ports[position].capacity}',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
fontSize:
12,
),
),
],
),
),
],
),
),
Padding(
padding: EdgeInsetsDirectional
.fromSTEB(10, 10, 10, 10),
child: LinearPercentIndicator(
percent: 0.75,
width:
MediaQuery.of(context)
.size
.width *
0.89,
lineHeight: 30,
animation: true,
progressColor:
FlutterFlowTheme
.of(context)
.primaryColor,
backgroundColor:
FlutterFlowTheme.of(
context)
.background,
center: Text(
'75%',
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'Heebo',
color:
Colors.black,
),
),
barRadius:
Radius.circular(8)),
),
],
),
),
));
// return Text('success');
// return _buildPageItem(position, devices.deviceList[position]);
}),
),
))),
),
),
),
如果这些代码仍然不适合您,请与我联系。 rasityilmaz@yaani.com