1

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'];
0

2 Answers 2

1

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]}'),
        );
      },
    ),
  )
Sign up to request clarification or add additional context in comments.

2 Comments

if this is not working could you include an image of the result on your phone? @Mert
Thanks for the answer but there is no another scroll
1

In your code, your ListView is within a Column which can't scroll. So wrap your ListView in an Expanded widget:

  Expanded(
            child: ListView.builder(
              shrinkWrap: true,

              itemCount: entries.length,
              scrollDirection: Axis.vertical,
              itemBuilder: (BuildContext context, int index) {
                return ListTile(
                  title: Text('Item ${entries[index]}'),
                );
              },
            ),
          )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.