简体   繁体   中英

How to make flutter container scrolling?

I am very new in Flutter, I want to make commented container scroll able. Nd I don't want to give height to container How can I achieve this? Is there any other widget which I can use other than container? I really need help, all my dearer freinds around the globe please help me in finding the solution.

String dropdownValue = 'One';
Widget _DropDown(BuildContext context) {
  return DropdownButton<String>(
    value: dropdownValue,
    icon: Icon(Icons.arrow_downward),
    iconSize: 24,
    elevation: 16,
    style: TextStyle(
        color: Colors.deepPurple
    ),
    underline: Container(
      height: 2,
      color: Colors.deepPurpleAccent,
    ),
    onChanged: (String newValue) {
      setState(() {
        dropdownValue = newValue;
      });
    },
    items: dropdownvalue
        .map<DropdownMenuItem<String>>((String value) {
      return DropdownMenuItem<String>(
        value: value,
        child: Text(value),
      );
    })
        .toList(),
  );
}

Widget _myListView(BuildContext context) {
  return ListView.separated(
    itemCount:initialAttendance == null ? 0 : initialAttendance.length,
    itemBuilder: (context, index) {
      return Card(

        elevation: 8.0,
        child: ClipPath(
          clipper: ShapeBorderClipper(shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(3))),

          child: Container(
            decoration: BoxDecoration(
                border: Border(left: BorderSide(color: Color(0xffffc909), width: 5))),
            child: Padding(

              padding: const EdgeInsets.all(8.0),
              child: Column(
                children: <Widget>[
                  Container(
                      child: Row(
                        children: <Widget>[
                          Container(
                              padding: EdgeInsets.only(left: 6),
                              child: Text(initialAttendance[index].toUpperCase(),style: TextStyle(fontWeight: FontWeight.bold),))

                        ],
                      )
                  ),

                  Container(
                      child: Row(
                        children: <Widget>[
                          Container(
                              padding: EdgeInsets.only(left: 6),
                              child: Text(initialAttendance1[index].toUpperCase(),style: TextStyle(fontWeight: FontWeight.bold),))

                        ],
                      )
                  ),
                  Container(
                      child: Row(
                        children: <Widget>[
                          Container(
                              padding: EdgeInsets.only(left: 6),
                              child: Text(initialAttendance2[index].toUpperCase(),style: TextStyle(fontWeight: FontWeight.bold),))

                        ],
                      )
                  ),
                  Container(
                      child: Row(
                        children: <Widget>[
                          Container(
                              padding: EdgeInsets.only(left: 6),
                              child: Text(initialAttendance3[index].toUpperCase(),style: TextStyle(fontWeight: FontWeight.bold),))

                        ],
                      )
                  ),
                ],
              ),
            ),
          ),
        ),
      );
    },
    separatorBuilder: (context, index) {
      return Divider();
    },
  );
}

return Scaffold(
  appBar: AppBar(
      title: new Text("Datesheet".toUpperCase()  , style: TextStyle(
          fontWeight: FontWeight.bold
      ), ),
      backgroundColor: Color(0xff007ba4),
      elevation: .1
  ),
    body: ListView(
        children: <Widget>[
            Container(
               height: 50,
               child: Padding(
                 padding: const EdgeInsets.all(10.0),
                   child: _DropDown(context)
               )
           ),
              ***Container( // I want this container to be scrollable
                  height: 600,
                  color: Color(0xff47b5be),
                child: Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: _myListView(context)
                )***
            )
         ]
     ),
  );

}

You Can use

    Container(
  child: new SingleChildScrollView(
    child: new Column(
      children: <Widget>[
        _showChild1(),
        _showChild2(),
        ...
        _showChildN()
      ]
    )
  )
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM