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
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()
),
);
},
)
],
);
}
}
2
Answers
Can you try to replace ListView.builder with this code
Let me know if is this helpful to you
Wrap your
ListView
withExpanded
widget.I will highly recommend checking this video