Reputation: 43
I have a HomePage with DataTable with several hundred rows, which takes a while to load. The HomePageState reloads every time I sort the data table - while building, the whole page freezes for a second or two.
Is it possible to add a progress indicator, build the new state in the background and show it after the build is done?
In other words, I want this to happen when a user sorts the table:
Upvotes: 2
Views: 880
Reputation: 34270
Hoping you are using FutureBuilder
for getting data.
FutureBuilder(
future: fetchData(),
builder: (_, dataSnapshot) {
if (dataSnapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else {
return Container(), // Your widgets code
);
}
},
)
inside else block get data like dataSnapshot.data
-- Use this to render widgets.
Upvotes: 1