为什么我不能在容器中放置高度变量而不是数字?

Why I can't put a height var instead of a num in the container?

我有这个容器,里面有一个Streambuilder,里面有一个ListView.builder(),我想让容器在逻辑上适应不同手机的不同高度,不知道为什么,但是在这个容器里我可以'除了纯 obviuos 数字外,在 height 方法中放入任何东西,看看当我放入 var 时整个容器消失。

代码:

var device_data = MediaQueryData();
    var size = device_data.size;
    var height = size.height;
return Stack(
      children: [
        Container(
          height: height * 0.7,
          child: StreamBuilder<Object>(
            stream: _store
                .collection('Khatma Collection')
                .document('Khatma 1')
                .collection('Videos')
                .snapshots(),
            builder: (context, AsyncSnapshot snapshot) {
              if (snapshot.hasData) {
                return ListView.builder(
                  shrinkWrap: true,
                  itemCount: snapshot.data.documents.length,
                  itemBuilder: (context, i) {
                    var link = snapshot.data.documents[i].data['Link'];
                    var uploader = snapshot.data.documents[i].data['Uploader'];
                    var likes = snapshot.data.documents[i].data['Likes'];
                    var like = likes.toString();
                    bool liked;
                    if (int.parse(like) > 0) {
                      liked = true;
                    } else if (int.parse(like) == 0) {
                      liked = false;
                    }
                    ..............

我认为你错过了 context

你试过这个吗?

Container(
    height: MediaQuery.of(context).size.height*0.7
    ...
)