fl_chart
fl_chart copied to clipboard
Ability to show a default graph when no data is found
I am using Riverpod for state management and I use its builtin stream and/or future providers. With these providers, I get a unique functionality where I can use them like this: aFutureProvider.when(data: (data){}, loading: (){}, error: (error, stackTrace){}
.
I have tried but found no documentation for this: I want to show an "empty" Line Chart (or any other chart) with a circular progress indicator for the loading case, an "empty" chart with the error in the middle in the case of error AND a string that says "No data found" in the middle of an empty chart when the data is successfully loaded but it turns out that there is no data (the table or collection is empty).
If this is possible to achieve, if anyone can point me in the right direction, I'd really appreciate it.
Flutter is a highly customizable library. You need to handle it by yourself. check if you have data, and return a chart. Otherwise, return anything else you want. Or show an overlaid progress indicator
@imaNNeoFighT You are absolutely right. I could do this myself. It just seemed like a basic feature because nobody ever (I assume) would use a static chart data in a production app. Most of the time, the data comes from a Future or a Stream and you would want widgets/charts for the case when there is no data. I wanted to be sure if such functionality wasnt already there.