Flutter I';我试图将object.parameter传递到自定义小部件中,但失败了
一般来说,我对颤振和编程是新手。 我正在创建一个扩展磁贴,当像标签值字段一样扩展时,会有更多关于公司的数据Flutter I';我试图将object.parameter传递到自定义小部件中,但失败了,flutter,dart,Flutter,Dart,一般来说,我对颤振和编程是新手。 我正在创建一个扩展磁贴,当像标签值字段一样扩展时,会有更多关于公司的数据 import 'package:flutter/material.dart'; import '../Object.dart'; class CompanyCardStyle extends StatelessWidget { final Company company; CompanyCardStyle({this.company}); @override Widget buil
import 'package:flutter/material.dart';
import '../Object.dart';
class CompanyCardStyle extends StatelessWidget {
final Company company;
CompanyCardStyle({this.company});
@override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
child: ExpansionTile(
title: Text(company.name),
children: <Widget>[
Container(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
companyLabels('Phone Number'),
companyLabels('Opportunities'),
companyLabels('Pipeline Revenue'),
companyLabels('Revenue Achieved'),
],
),
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
companyValues(company.phoneNumber),
SizedBox(
height: 10,
),
Text(
company.opportunities.toString(),
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: 'Raleway', fontSize: 15.0),
),
SizedBox(
height: 10,
),
Text(
company.pRevenue.toString(),
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: 'Raleway', fontSize: 15.0),
),
SizedBox(
height: 10,
),
Text(
company.revenueAchieved.toString(),
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: 'Raleway', fontSize: 15.0),
)
],
),
)
]))
],
leading: CircleAvatar(child: Text(company.name[0])),
subtitle: Text(company.address),
));
}
Widget companyLabels(String values) {
return Row(children: <Widget>[
Text(
values.toString(),
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: 'Raleway', fontSize: 15.0, fontWeight: FontWeight.bold),
),
SizedBox(
height: 30,
)
]);
}
Widget companyValues(Company values) {
return Row(
children: <Widget>[
Text(
company.values.toString(),
textAlign: TextAlign.left,
style: TextStyle(fontFamily: 'Raleway', fontSize: 15.0),
),
SizedBox(
height: 10,
)
],
);
}
}
您的变量称为
值
。删除公司。
前缀。此行存在问题
companyValues(company.phoneNumber),
您正在传递字符串,但在函数中,您的参数是公司
对象
Widget companyValues(Company values)
如果我离开公司。前缀,然后我必须传递company.phoneNumber调用companyValues函数时,它会说
参数类型int不能传递给参数类型company
也不能传递给参数类型company.phoneNumber.toString(),然后将类型从company
更改为String
。
Widget companyValues(Company values)