Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Listview does not scroll

The listview I have used in the application I am making with flutter cannot be scrolled. I tried everything but couldn’t find the solution.There is no other scroll in the code tree.I also added pysics but it still didn’t work. How can i fix this? I’m leaving all the code below. Thank you from now.
Here is my code:

Container(
      height: ScreenSize.getScreenHeight(context),
      width: ScreenSize.getScreenWidth(context),
      decoration: Background.setBackground,
      child: Column(
        children: [
          const SizedBox(
            height: 30,
          ),
          const Text(
            "Oylama Oluştur",
            style: TextStyle(
              fontSize: 30,
              fontWeight: FontWeight.w600,
            ),
          ),
          const SizedBox(
            height: 15,
          ),
          const Divider(
            color: Colors.black,
            indent: 25,
            endIndent: 25,
          ),
          const SizedBox(
            height: 50,
          ),
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Container(
              //height: ScreenSize.getScreenHeight(context)/2-20,
              width: ScreenSize.getScreenWidth(context) / 1.2,
              decoration: const BoxDecoration(
                borderRadius: BorderRadius.all(const Radius.circular(10)),
              ),
              child: TextFormField(
                onChanged: null,
                decoration: const InputDecoration(
                  hintText: '   Oylama başlığı giriniz',
                  hintStyle: TextStyle(
                    color: Colors.grey,
                    fontSize: 16.0,
                  ),
                  //labelText: "Name" ,
                  labelStyle: TextStyle(
                    color: Colors.black,
                  ),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(10)),
                    borderSide: BorderSide(color: Colors.black, width: 2),
                  ),
                  focusedBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(10)),
                    borderSide: BorderSide(color: Colors.black, width: 2),
                  ),
                ),
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.all(8),
            child: SizedBox(
              width: ScreenSize.getScreenWidth(context) / 1.2,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    //height: ScreenSize.getScreenHeight(context)/2-20,
                    width: ScreenSize.getScreenWidth(context) / 2,
                    decoration: const BoxDecoration(
                      borderRadius:
                          BorderRadius.all(const Radius.circular(10)),
                    ),
                    child: TextFormField(
                      onChanged: null,
                      decoration: const InputDecoration(
                        hintText: '  Ekle',
                        hintStyle: TextStyle(
                          color: Colors.grey,
                          fontSize: 16.0,
                        ),
                        //labelText: "Name" ,
                        labelStyle: TextStyle(
                          color: Colors.black,
                        ),
                        border: OutlineInputBorder(
                          borderRadius:
                              BorderRadius.all(Radius.circular(10)),
                          borderSide:
                              BorderSide(color: Colors.black, width: 2),
                        ),
                        focusedBorder: OutlineInputBorder(
                          borderRadius:
                              BorderRadius.all(Radius.circular(10)),
                          borderSide:
                              BorderSide(color: Colors.black, width: 2),
                        ),
                      ),
                    ),
                  ),
                  SizedBox(
                    width: ScreenSize.getScreenWidth(context) / 4,
                    height: 60,
                    child: ElevatedButton(
                      onPressed: () {},
                      style: ElevatedButton.styleFrom(
                          primary:
                              const Color.fromARGB(222, 167, 162, 162),
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10))),
                      child: const Text("Ekle",
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            fontSize: 20,
                            fontWeight: FontWeight.bold,
                          )),
                    ),
                  ),
                ],
              ),
            ),
          ),
          ListView.builder(
            itemCount: entries.length,
            scrollDirection: Axis.vertical,
            shrinkWrap: true,
            
            itemBuilder: (BuildContext context, int index) {
              return ListTile(
                title: Text('Item ${entries[index]}'),
              );
            },
          )
          //button(context),
        ],
      )),

Here is the list:

final List<String> entries = <String>['A', 'B', 'C', 'B', 'C', 'B', 'C', 'B', 'C', 'B', 'C', 'B', 'C', 'C', 'B', 'C', 'C', 'B', 'C'];

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Wrap your ListView with Expanded to get all the space available in column:

Expanded(
    child: ListView.builder(
      itemCount: entries.length,
      scrollDirection: Axis.vertical,
      shrinkWrap: true,
      itemBuilder: (BuildContext context, int index) {
        return ListTile(
          title: Text('Item ${entries[index]}'),
        );
      },
    ),
  )
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading