Flutter ListView 不显示项目

Flutter ListView is not displaying items

我正在尝试设置一个非常简单的 ListView 从屏幕顶部到底部,但现在我在屏幕上看不到任何东西,只有 绿色 背景。

class _HomeScreenState extends State<HomeScreen> {


List wishlists = [Wishlist("Test1"), Wishlist("Yeet")];

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.lightGreen,
      child: SizedBox(
        height: 400,
        child: new ListView.builder(
          scrollDirection: Axis.vertical,
          shrinkWrap: true,
          itemBuilder: (BuildContext context, int index) {
            return new WishlistListWidget(
              wishlist: wishlists[index],
            );
          },
          itemCount: wishlists.length,
        ),
      ),
    );
  }
}

Wishlist 是一个简单的 Class,这是我的 WishlistListWidget:

class WishlistListWidget extends StatelessWidget {


final Wishlist wishlist;
  const WishlistListWidget({Key key, this.wishlist}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Row(
        children: [
          Container(
            height: 150.0,
            color: Colors.transparent,
            child: new Container(
              decoration: new BoxDecoration(
                  color: Colors.red,
                  borderRadius: new BorderRadius.only(
                    topLeft: const Radius.circular(40.0),
                    bottomLeft: const Radius.circular(40.0),
                  )),
            ),
          ),
        ],
      ),
    );
  }
}

我在这里错过了什么?

您在 WishlistListWidget class 中缺少 Text 小部件。

class WishlistListWidget extends StatelessWidget {
  final Wishlist wishlist; // this value is not being used here
  const WishlistListWidget({Key key, this.wishlist}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Row(
        children: [
          Container(
            height: 150.0,
            color: Colors.transparent,
            child: new Container(
              child: Text(wishlist.someProperty), // this one, it should be wishlist.someProperty
              decoration: new BoxDecoration(
                color: Colors.red,
                borderRadius: new BorderRadius.only(
                  topLeft: const Radius.circular(40.0),
                  bottomLeft: const Radius.circular(40.0),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}