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

ListTile not showing when added to listview

I am working on a leaderboard system where it sorts the map and it displays the keys on a listTile that’s inside a listView, but when I reload the app, It won’t show any listTiles
here is the picture
Any help is appreciated
here is the code for this widget

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

Map players = {"Hello": 1468, "Ableflyer": 1820, "crazyman": 1536, "gottoosilly": 2160};
Map sortplayer = Map.fromEntries(players.entries.toList()..sort((e1, e2) => e1.value.compareTo(e2.value)));
class daily extends StatelessWidget {
  const daily({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ListView.builder(
          itemCount: sortplayer.length,
          itemBuilder: (BuildContext context, int index){
            return ListTile(
              title: Text(
                  sortplayer.keys.elementAt(index).toString()
              ),
            );
          },
        )
      ],
    );
  }
}

>Solution :

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

Wrap your ListView with Expanded widget.

class daily extends StatelessWidget {
  const daily({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Expanded(
          child: ListView.builder(
            itemCount: sortplayer.length,
            itemBuilder: (BuildContext context, int index) {
              return ListTile(
                title: Text(sortplayer.keys.elementAt(index).toString()),
              );
            },
          ),
        )
      ],
    );
  }
}

I will highly recommend checking this video

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