Flutterの例にあるcards_demo.dart
を修正しようとしています。私の目的は、組み込みの2枚のカードの高さをFlutter Galleryデモ:カードの高さを変更するカード
static final double height=300.0
(またはいくつかの必須および固定数)として固定する代わりに、2枚のカードの高さを変えたいとします。
だから私は、プロパティheight
を含めるようにTravelDestination
クラスを変更:
class TravelDestination {
const TravelDestination({ this.assetName, this.title, this.description, this.height });
final String assetName;
final String title;
final List<String> description;
final double height;
bool get isValid => assetName != null && title != null && description?.length == 3;
}
その後、クラスTravelDestinationItem
build
機能に:
class TravelDestinationItem extends StatelessWidget {
TravelDestinationItem({ Key key, @required this.destination }) : super(key: key) {
assert(destination != null && destination.isValid);
}
static final double height = 512.0;
final TravelDestination destination;
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white);
final TextStyle descriptionStyle = theme.textTheme.subhead;
return new Container(
padding: const EdgeInsets.all(8.0),
height: destination.height,
//height: height,
child: new Card(
child: new Column(... ...
私は2枚のカードに異なるheight
プロパティが割り当てられますが、結果は動作していません。これはまだstatic final double height
で指定されている高さです。
私はstatic final double height
行をコメントアウトした場合、コンパイラは私を思い出させます:No static getter 'height' declared...
私は非常に混乱し、この動作にしています。
誰でも手助けできますか?
ありがとうございます!これは後で気づいた。 – TaylorR