我有两个小部件-是否可以将它们一起滚动?

时间:2018-08-25 16:23:18

标签: flutter flutter-layout

我有两个小部件,其中一个具有垂直列表视图。是否可以将两个小部件一起滚动?

下面是我的代码:

@override
  Widget build(BuildContext context) {
    var deviceSize = MediaQuery.of(context).size;

    return Container(
      child: Column(
        children: <Widget>[
          new GestureDetector(
            child: new Card(
              elevation: 2.0,
              margin: const EdgeInsets.all(5.0),
              child: new Stack(
                alignment: Alignment.center,
                children: <Widget>[
                  new Align(
                    child: new Container(
                      padding: const EdgeInsets.all(6.0),
                      child:
                      new Column(
                        mainAxisSize: MainAxisSize.min,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          new SizedBox(
                            child: new ChooseTopic(),
                            height: deviceSize.height * 0.28,
                          )



                        ],
                      ),

                      color: Colors.white70,
                      width: double.infinity,
                    ),
                    alignment: Alignment.bottomCenter,
                  ),
                ],
              ),
            ),
            onTap: () {},
          ),
          Expanded(child: Padding(padding: EdgeInsets.all(6.0),
          child: new StreamBuilder<QuerySnapshot>(
              stream: Firestore.instance.collection('First List').orderBy('sl',descending: false).snapshots(),
              builder: (BuildContext context,
                  AsyncSnapshot<QuerySnapshot> snapshot) {
                if (!snapshot.hasData) return new Center(
                  child: Text("Please Wait"),
                );
                return new ListView.builder(
                  scrollDirection: Axis.vertical,
                  itemCount: snapshot.data.documents.length,
                  itemBuilder: (_, int index) {
                    final DocumentSnapshot document = snapshot.data
                        .documents[index];
                    String name = document.data['name'];
                    return
                      new GestureDetector(
                        child: new Card(
                          elevation: 2.0,
                          margin: const EdgeInsets.all(5.0),
                          child: new Stack(
                            alignment: Alignment.center,
                            children: <Widget>[
                              new Align(
                                child: new Container(
                                  padding: const EdgeInsets.all(6.0),
                                  child:
                                  new Column(
                                    mainAxisSize: MainAxisSize.min,
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: <Widget>[
                                      new SizedBox(
                                        child: new EduCategory(listcategory: name,intp: index.toInt(),),
                                        height: deviceSize.height * 0.28,
                                      )


                                    ],
                                  ),

                                  color: Colors.white70,
                                  width: double.infinity,
                                ),
                                alignment: Alignment.bottomCenter,
                              ),
                            ],
                          ),
                        ),
                        onTap: () {},
                      );
                  },
                );
              }
          ),))
        ],
      )



    );

  }
}

0 个答案:

没有答案