SfCartesianChart in SingleChildScrollView updated by NotificationListener<ScrollNotification> with error message.

Hello,

I want to update a SfCartesianChart in an SingleChildScrollView by pulling/dragging the chart in the scrollwiew from the left end to the right. A NotificationListener<ScrollNotification> triggers the update when I get an OverscrollNotification:

the update is working but I get ​the following error message :

======== Exception caught by gesture library =======================================================
The following assertion was thrown while dispatching a pointer event:
'package:flutter/src/rendering/object.dart': Failed assertion: line 2469 pos 12: 'attached': is not true.
.....

full error message at the end of this post.

When I use a Listview.builder instead of the SfCartesianChart I get no error

I use the last Flutter Syncfusion library with the latest Flutter stable  and the build is for Android:

syncfusion_flutter_charts: ^19.4.42
Flutter (Channel stable, 2.8.1)

Can you help me get rid of the error message ?

best regards

jg

My code:


import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
home: Scaffold(
appBar: AppBar(
title: const Text('SingleChildScrollView'),
),
body: const Center(
child: SingleChildScrollViewHome(),
),
),
);
}
}

class Data {
Data(this.year, this.value);

final int year;
final double value;
}

Future<List<Data>> dataListFutureFunc(int update) async {
return Future<List<Data>>.delayed(const Duration(seconds: 3), () {
List<Data> data = [
Data(1990, 135 * update.toDouble()),
Data(1991, 134),
Data(1992, 137),
];
return data;
});
}

class SingleChildScrollViewHome extends StatefulWidget {
const SingleChildScrollViewHome({
Key? key,
}) : super(key: key);

@override
_SingleChildScrollViewHome createState() => _SingleChildScrollViewHome();
}

class _SingleChildScrollViewHome extends State<SingleChildScrollViewHome> {
final ScrollController _controller = ScrollController();
DateTime lastUpdated = DateTime.now();
int update = 0;
late Future<List<Data>> _dataListFuture;

@override
void initState() {
_dataListFuture = dataListFutureFunc(update);
super.initState();
}

@override
Widget build(BuildContext context) {
return NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
if (scrollNotification is OverscrollNotification) {
if (scrollNotification.overscroll < -5.0) {
final timeUpdate = DateTime.now();
if (lastUpdated
.add(const Duration(seconds: 5))
.isBefore(timeUpdate)) {
lastUpdated = timeUpdate;
setState(() {
update += 1;
_dataListFuture = dataListFutureFunc(update);
});
return false;
}
}
} else {}
return false;
},
child: SingleChildScrollView(
controller: _controller,
scrollDirection: Axis.horizontal,
child: SizedBox(
width: 600,
height: 300,
child: FutureBuilder<List<Data>>(
future: _dataListFuture,
builder: (BuildContext context,
AsyncSnapshot<List<Data>> snapshot) {
print("connectionState: ${snapshot.connectionState}");
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
case ConnectionState.active:
{
return const Center(
child: Text('waiting...'),
);
}
case ConnectionState.done:
{
// NO error message when using a ListView.builder:

// return ListView.builder(
// controller: _controller,
// scrollDirection : Axis.horizontal,
// itemBuilder: (BuildContext context, int index) {
// return Card(child: Text('Item ${snapshot.data?[index].value}'));
// },
// itemCount: snapshot.data?.length,
// );

return SfCartesianChart(
series: <ChartSeries<Data, int>>[
SplineSeries<Data, int>(
dataSource: snapshot.data!,
xValueMapper: (Data d, _) => d.year,
yValueMapper: (Data d, _) => d.value,
)
]);
}
}
}),
),
));
}
}


the full error message when I pull/drag the chart to the right for update:


======== Exception caught by gesture library =======================================================
The following assertion was thrown while dispatching a pointer event:
'package:flutter/src/rendering/object.dart': Failed assertion: line 2469 pos 12: 'attached': is not true.




Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md


When the exception was thrown, this was the stack:
#2 RenderObject.getTransformTo (package:flutter/src/rendering/object.dart:2469:12)
#3 RenderBox.globalToLocal (package:flutter/src/rendering/box.dart:2525:31)
#4 ContainerArea._performPointerUp (package:syncfusion_flutter_charts/src/chart/base/chart_base.dart:3176:39)
#5 ContainerArea.build.<anonymous closure>.<anonymous closure> (package:syncfusion_flutter_charts/src/chart/base/chart_base.dart:2333:21)
#6 RenderPointerListener.handleEvent (package:flutter/src/rendering/proxy_box.dart:2892:27)
#7 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
#8 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:322:11)
#9 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
#10 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
#11 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
#12 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
#16 _invoke1 (dart:ui/hooks.dart:169:10)
#17 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:293:7)
#18 _dispatchPointerDataPacket (dart:ui/hooks.dart:88:31)
(elided 5 frames from class _AssertionError and dart:async)
Event: PointerUpEvent#66693(position: Offset(400.0, 518.3))
  position: Offset(400.0, 518.3)
Target: RenderPointerListener#43c38 DISPOSED
  needs compositing
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=580.0, h=280.0)
  size: Size(580.0, 280.0)
  behavior: deferToChild
  listeners: down, move, up, signal
====================================================================================================

9 Replies 1 reply marked as answer

YG Yuvaraj Gajaraj Syncfusion Team January 13, 2022 03:02 PM UTC

Hi Jean Gul, 

Greetings from Syncfusion. We are analyzing your scenario, since we need time on this, we will update the status in two business days (17 Jan 2022). 
  
Regards, 
Yuvaraj. 



JG Jean Guldener replied to Yuvaraj Gajaraj January 13, 2022 08:04 PM UTC

Hi Yuvaraj,

thank you for you interest

regards

Jean



YG Yuvaraj Gajaraj Syncfusion Team January 16, 2022 04:04 PM UTC

Hi Jean Gul, 
 
Most welcome, we will update you on the status earlier. 
  
Regards, 
Yuvaraj. 



YG Yuvaraj Gajaraj Syncfusion Team January 17, 2022 12:24 PM UTC

Hi Jean Gul, 
 
Sorry for inconvenience. 
We have analyzed your query and we have tried to reproduce the reported issue regarding getting exception when scroll the chart in SingleChildScrollView, it gets reproduce at our end. So, we consider this as a bug and we will fix and rolled out in our next weekly patch, it will expect on 25th January 2022. 
 
Regards, 
Yuvaraj. 



JG Jean Guldener January 17, 2022 03:02 PM UTC

Yuvaraj Gajaraj,


Thank you for your response, I wait for your next weekly patch!


Regards

Jean G.




YG Yuvaraj Gajaraj Syncfusion Team January 18, 2022 01:27 PM UTC

Hi Jean Gul, 
 
Most welcome, as stated earlier we will update you once the release got rolled out and we appreciate your patience until then. 
 
Regards, 
Yuvaraj. 



YG Yuvaraj Gajaraj Syncfusion Team January 25, 2022 01:27 PM UTC

Hi Jean Gul, 
 
Thanks for your patience. The reported issue regarding getting attached exception while scroll the chart inside the scrollable widget is fixed and rolled out in our weekly patch release. To avoid this issue please update the chart package to the latest version mentioned below. 
 
 
Regards, 
Yuvaraj. 



JG Jean Guldener January 25, 2022 02:24 PM UTC

Hi Yuvaraj Gajaraj,


I have tested version 19.4.47  on my main project and it works perfectly!

Thank you very much for you help!


best regards


Jean G.


Marked as answer

DD Dharanidharan Dharmasivam Syncfusion Team January 26, 2022 02:03 PM UTC

Hi Jean,
 

 
Most welcome. Kindly revert us if you have further queries, we are always happy in assisting you. 

 
Thanks, 
Dharani. 


Loader.
Up arrow icon