Question regarding RefreshIndicator

Hi,

first of all thank you for your wonderful and easy to use diagrams.
I have a question regarding the animation that is performed when a diagram is created. When I use a RefreshIndicator on Flutter and the user starts to drag the indicator down, the loading animation is restarted, even though the page is neither rebuilt nor updated. This leads to the fact that the loading animation is executed very often and not only when a page is opened.

Many greetings,
Daniel

5 Replies

SK Sriram Kiran Senthilkumar Syncfusion Team April 27, 2020 09:35 AM UTC

Hi Daniel,

Thanks for using our Flutter Chart widget. We have analyzed your scenario and we would like to let you know that, by default, if there are any changes in data sources, then the changed data point will get animated on refreshing the changes. This is our default behaviour. If you wish not to animate the series when there is any change, you can specify the animationDuration to 0 with the onRefresh method of refresh indicator. So that the chart widget will animate on the initial rendering and on pull down with refresh indicator, the animation will not happen. Find the code below to achieve this.


double chartAnimationDuration = 1500;

Future<void> refresh() {
    chartAnimationDuration = 0;
    //Other configurations 
    return Future.value();
  }


  SfCartesianChart(
                      series: <LineSeries<ChartSampleData, num>>[
                        LineSeries<ChartSampleData, num>(
                            dataSource: chartData,
                            animationDuration: chartAnimationDuration,
                         ),
                      ],
                    )


And we would like to let you know that, while using the onRefresh function in RefreshIndicator, this will call the didChangeDependencies and build methods of the respective widgets, so the changes got reflected back. We have also attached a sample for your reference, which can be found below.

Sample:
 
Thanks,
Sriram Kiran. 



DA Daniel April 27, 2020 10:10 AM UTC

Hi Sriram,

thanks for your answer.
The problem does not occur when the user reloads the page, but when the user pulls the RefreshIndicator without reloading the page. Neither the build method nor the onRefresh method of the RefreshIndicator is called in this case. I have created a small gif to illustrate the problem.

Many greetings,
Daniel

Attachment: Example_94ab4acb.zip


SK Sriram Kiran Senthilkumar Syncfusion Team April 28, 2020 09:15 AM UTC

Hi Daniel,

Thanks for the information. On analyzing with the provided gif images, we found that the refresh indicator calls the chart widget's didChangeDependencies and build method, so the animation has occurred. To overcome this scenario, you can use the StreamBuilder and then you can initialize the chart widget and now this will work as per your expectation. We have attache sample for your reference which can be found below. Kindly make sure this works at your end. 
 
 
Thanks,
Sriram Kiran.



DA Daniel April 28, 2020 09:47 AM UTC

Hi Sriram,

thank you very much.
I have just tested the solution and it works great.

Best regards,
Daniel


DD Dharanidharan Dharmasivam Syncfusion Team April 29, 2020 06:22 AM UTC

Hi Daniel, 
 
Thanks for your revert. Kindly revert us if you have any other queries. We are always happy in assisting you. 
 
Thanks, 
Dharani. 


Loader.
Up arrow icon