Я новичок в флаттере и программировании в целом. Я создаю плитку расширения с дополнительными данными о компании при расширении, например в полях значений метки.
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, как виджет companyLabels, у меня есть объект компании в Object .dart файл.
Когда я пытаюсь передать параметры компании в виджет companyValues, я получаю сообщение об ошибке the getter 'values' is'nt defined for the type company
Также, пожалуйста, дайте мне знать, как лучше всего следовать при достижении чего-либо вот так.
Объект компании
String name;
String address;
int phoneNumber;
int opportunities;
int pRevenue;
int revenueAchieved;
Company(
{this.name,
this.address,
this.opportunities,
this.pRevenue,
this.phoneNumber,
this.revenueAchieved});
}```