我从演示中复制了该代码的基本结构,并根据自己的需要对其进行了调整(并针对这个问题进行了缩减)。
但我对一些事情感到困惑。也许 Dart 专家可以启发我......
import 'package:flutter/material.dart';
// Show policy widget - shows
class ShowPolicy extends StatelessWidget {
final Policy policy;
ShowPolicy(this.policy);
@override
Widget build(BuildContext context) {
return Text('Test text ' + policy.riskName + ' ' + policy.policyNumber);
}
}
// Policy class
class Policy {
final String riskName;
final String policyNumber;
Policy( { this.riskName, this.policyNumber } );
}
// what is this variable doing here?. Shouldn't it be an a class?
List<Policy> allPolicies = [
Policy(riskName: 'Lilly', policyNumber: 'PY123456-4'),
Policy(riskName: …Run Code Online (Sandbox Code Playgroud)