Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when sink is passed to touchResponseSink #64

Closed
janstol opened this issue Aug 29, 2019 · 4 comments
Closed

Exception when sink is passed to touchResponseSink #64

janstol opened this issue Aug 29, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@janstol
Copy link

janstol commented Aug 29, 2019

When I pass sink to the chart (touchResponseSink: controller.sink), the app throws following exception on touch event end (when I lift finger off the screen):

I/flutter (12415): ══╡ EXCEPTION CAUGHT BY FOUNDATION LIBRARY ╞════════════════════════════════════════════════════════
I/flutter (12415): The following assertion was thrown while dispatching notifications for FlTouchInputNotifier:
I/flutter (12415): 'package:flutter/src/rendering/object.dart': Failed assertion: line 1930 pos 12: 'owner == null ||
I/flutter (12415): !owner.debugDoingPaint': is not true.
I/flutter (12415): 
I/flutter (12415): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (12415): more information in this error message to help you determine and fix the underlying cause.
I/flutter (12415): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (12415):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (12415): 
I/flutter (12415): When the exception was thrown, this was the stack:
I/flutter (12415): #2      RenderObject.markNeedsPaint (package:flutter/src/rendering/object.dart:1930:12)
I/flutter (12415): #3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:206:21)
I/flutter (12415): #4      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:273:5)
I/flutter (12415): #5      BaseChartPainter.releaseIfEndTouch (package:fl_chart/src/chart/base/base_chart/base_chart_painter.dart:132:26)
I/flutter (12415): #6      LineChartPainter.paint (package:fl_chart/src/chart/line_chart/line_chart_painter.dart:104:7)
I/flutter (12415): #7      RenderCustomPaint._paintWithPainter (package:flutter/src/rendering/custom_paint.dart:528:13)
I/flutter (12415): #8      RenderCustomPaint.paint (package:flutter/src/rendering/custom_paint.dart:566:7)
I/flutter (12415): #9      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #10     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #11     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #12     RenderPointerListener.paint (package:flutter/src/rendering/proxy_box.dart:2669:11)
I/flutter (12415): #13     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #14     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #15     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #16     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #17     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #18     RenderShiftedBox.paint (package:flutter/src/rendering/shifted_box.dart:70:15)
I/flutter (12415): #19     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #20     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #21     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #22     RenderDecoratedBox.paint (package:flutter/src/rendering/proxy_box.dart:1953:11)
I/flutter (12415): #23     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #24     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #25     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #26     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #27     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #28     _RenderCustomMultiChildLayoutBox&RenderBox&ContainerRenderObjectMixin&RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:2509:15)
I/flutter (12415): #29     RenderCustomMultiChildLayoutBox.paint (package:flutter/src/rendering/custom_layout.dart:361:5)
I/flutter (12415): #30     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #31     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #32     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #33     _RenderInkFeatures.paint (package:flutter/src/material/material.dart:510:11)
I/flutter (12415): #34     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #35     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #36     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #37     PaintingContext.pushLayer (package:flutter/src/rendering/object.dart:369:12)
I/flutter (12415): #38     RenderPhysicalModel.paint (package:flutter/src/rendering/proxy_box.dart:1724:15)
I/flutter (12415): #39     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #40     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #41     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #42     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #43     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:172:13)
I/flutter (12415): #44     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:123:15)
I/flutter (12415): #45     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2089:7)
I/flutter (12415): #46     PaintingContext._repaintCompositedChild (package:flutter/src/rendering/object.dart:127:11)
I/flutter (12415): #47     PaintingContext.repaintCompositedChild (package:flutter/src/rendering/object.dart:95:5)
I/flutter (12415): #48     PipelineOwner.flushPaint (package:flutter/src/rendering/object.dart:858:29)
I/flutter (12415): #49     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:348:19)
I/flutter (12415): #50     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
I/flutter (12415): #51     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
I/flutter (12415): #52     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15)
I/flutter (12415): #53     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9)
I/flutter (12415): #54     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:874:5)
I/flutter (12415): #58     _invoke (dart:ui/hooks.dart:236:10)
I/flutter (12415): #59     _drawFrame (dart:ui/hooks.dart:194:3)
I/flutter (12415): (elided 5 frames from class _AssertionError and package dart:async)
I/flutter (12415): 
I/flutter (12415): The FlTouchInputNotifier sending notification was:
I/flutter (12415):   FlTouchInputNotifier#c0f42(Instance of 'NonTouch')
I/flutter (12415): ════════════════════════════════════════════════════════════════════════════════════════════════════

Sample:

import 'dart:async';

import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      title: "Chart",
      home: Scaffold(
        appBar: AppBar(title: Text("Chart"),),
        body: LineChartSample2(),
      ),
    )
  );
}


class LineChartSample2 extends StatefulWidget {

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

class _LineChartSample2State extends State<LineChartSample2> {

  StreamController<LineTouchResponse> controller;

  @override
  void initState() {
    super.initState();
    controller = StreamController();
    controller.stream.distinct().listen((LineTouchResponse response){
      /// do whatever you want and change any property of the chart.
    });
  }

  @override
  void dispose() {
    controller.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AspectRatio(
      aspectRatio: 1,
      child: Container(
        decoration: BoxDecoration(
            color: Color(0xff232d37)
        ),
        child: Padding(
          padding: const EdgeInsets.only(right: 18.0, left: 12.0, top: 24, bottom: 12),
          child: FlChart(
            chart: LineChart(
              LineChartData(
                lineTouchData: LineTouchData(touchResponseSink: controller.sink),
                gridData: FlGridData(
                  show: true,
                  drawHorizontalGrid: true,
                  getDrawingVerticalGridLine: (value) {
                    return const FlLine(
                      color: Color(0xff37434d),
                      strokeWidth:  1,
                    );
                  },
                  getDrawingHorizontalGridLine: (value) {
                    return const FlLine(
                      color: Color(0xff37434d),
                      strokeWidth: 1,
                    );
                  },
                ),
                titlesData: FlTitlesData(
                  show: true,
                  bottomTitles: SideTitles(
                    showTitles: true,
                    reservedSize: 22,
                    textStyle: TextStyle(
                        color: const Color(0xff68737d),
                        fontWeight: FontWeight.bold,
                        fontSize: 16
                    ),
                    getTitles: (value) {
                      switch(value.toInt()) {
                        case 2: return 'MAR';
                        case 5: return 'JUN';
                        case 8: return 'SEP';
                      }

                      return '';
                    },
                    margin: 8,
                  ),
                  leftTitles: SideTitles(
                    showTitles: true,
                    textStyle: TextStyle(
                      color: const Color(0xff67727d),
                      fontWeight: FontWeight.bold,
                      fontSize: 15,
                    ),
                    getTitles: (value) {
                      switch(value.toInt()) {
                        case 1: return '10k';
                        case 3: return '30k';
                        case 5: return '50k';
                      }
                      return '';
                    },
                    reservedSize: 28,
                    margin: 12,
                  ),
                ),
                borderData: FlBorderData(
                    show: true,
                    border: Border.all(color: Color(0xff37434d), width: 1)
                ),
                minX: 0,
                maxX: 11,
                minY: 0,
                maxY: 6,
                lineBarsData: [
                  LineChartBarData(
                    spots: [
                      FlSpot(0, 3),
                      FlSpot(2.6, 2),
                      FlSpot(4.9, 5),
                      FlSpot(6.8, 3.1),
                      FlSpot(8, 4),
                      FlSpot(9.5, 3),
                      FlSpot(11, 4),
                    ],
                    isCurved: true,
                    barWidth: 5,
                    isStrokeCapRound: true,
                    dotData: FlDotData(show: false),
                    belowBarData: BelowBarData(show: false),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
@imaNNeo
Copy link
Owner

imaNNeo commented Aug 29, 2019

Thanks, let me check

@gavinerasmus
Copy link

Me too

@imaNNeo
Copy link
Owner

imaNNeo commented Sep 11, 2019

I'm on it

@imaNNeo imaNNeo added the bug Something isn't working label Sep 11, 2019
@imaNNeo
Copy link
Owner

imaNNeo commented Sep 11, 2019

Hey guys it is fixed on 0.2.1, but also 0.2.2 is available, sorry for the delay,
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants