Skip to content

'<optimized out>': is not true. #17

Closed

Description

@dotlenter

I'm trying to style the cells in my SfDataGrid with this code:

SfDataGridTheme( data: SfDataGridThemeData( headerStyle: DataGridHeaderCellStyle( backgroundColor: Colors.black54, textStyle: TextStyle( color: Colors.white, fontFamily: 'HNMed', fontSize: 12.sp, ), ), cellStyle: DataGridCellStyle( textStyle: TextStyle( fontFamily: 'HNMed', ), ), ), child: SfDataGrid(....), ),

The above code throws this error:

|I/flutter (12465): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════ I/flutter (12465): The following assertion was thrown during paint(): I/flutter (12465): 'dart:ui/painting.dart': Failed assertion: line 1147: '<optimized out>': is not true. I/flutter (12465): The relevant error-causing widget was: I/flutter (12465): _VirtualizingCellsRenderObjectWidget-[DataRow#88901] I/flutter (12465): file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_datagrid-18.3.38-beta/lib/src/control/cell_control/virtualizing_cells_widget.dart:22:12 I/flutter (12465): When the exception was thrown, this was the stack: I/flutter (12465): #2 Paint.color= (dart:ui/painting.dart:1147:12) I/flutter (12465): #3 _RenderVirtualizingCellsWidget._drawRowBackground (package:syncfusion_flutter_datagrid/src/control/cell_control/virtualizing_cells_widget.dart:204:35) I/flutter (12465): #4 _RenderVirtualizingCellsWidget.paint (package:syncfusion_flutter_datagrid/src/control/cell_control/virtualizing_cells_widget.dart:328:5) I/flutter (12465): #5 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2311:7)I/flutter (12465): #6 PaintingContext._repaintCompositedChild (package:flutter/src/rendering/object.dart:140:11) I/flutter (12465): #7 PaintingContext.repaintCompositedChild (package:flutter/src/rendering/object.dart:100:5) I/flutter (12465): #8 PipelineOwner.flushPaint (package:flutter/src/rendering/object.dart:978:29) I/flutter (12465): #9 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:438:19) I/flutter (12465): #10 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:914:13) I/flutter (12465): #11 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:302:5) I/flutter (12465): #12 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15) I/flutter (12465): #13 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9) I/flutter (12465): #14 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:864:7) I/flutter (12465): (elided 6 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, and dart:async-patch) I/flutter (12465): The following RenderObject was being processed when the exception was fired: _RenderVirtualizingCellsWidget#b8516: I/flutter (12465): needs compositing I/flutter (12465): creator: _VirtualizingCellsRenderObjectWidget-[DataRow#88901] ← I/flutter (12465): _VirtualizingCellsWidget-[DataRow#88901] ← _VisualContainerRenderObjectWidget ← _VisualContainer ← I/flutter (12465): ConstrainedBox ← _SingleChildViewport ← IgnorePointer-[GlobalKey#50be6] ← Semantics ←I/flutter (12465): _PointerListener ← Listener ← _GestureSemantics ← I/flutter (12465): RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#09b13] ← ⋯ I/flutter (12465): parentData: offset=Offset(0.0, 245.0) (can use size) I/flutter (12465): constraints: BoxConstraints(w=457.1, h=49.0) I/flutter (12465): layer: OffsetLayer#858a2 I/flutter (12465): size: Size(457.1, 49.0) I/flutter (12465): This RenderObject had the following descendants (showing up to depth 5): I/flutter (12465): child 1: _RenderGridCell#8a5c7 I/flutter (12465): child: RenderSemanticsAnnotations#7742b I/flutter (12465): child: RenderSemanticsGestureHandler#cd669 I/flutter (12465): child: RenderPointerListener#7ed6d I/flutter (12465): child: RenderDecoratedBox#ba529 I/flutter (12465): child 2: _RenderGridCell#a982f I/flutter (12465): child: RenderSemanticsAnnotations#1e823 I/flutter (12465): child: RenderSemanticsGestureHandler#1bf4c I/flutter (12465): child: RenderPointerListener#17434 I/flutter (12465): child: RenderDecoratedBox#b0207 I/flutter (12465): child 3: _RenderGridCell#aca11 I/flutter (12465): child: RenderSemanticsAnnotations#157c1 I/flutter (12465): child: RenderSemanticsGestureHandler#73e7d I/flutter (12465): child: RenderPointerListener#d4c76 I/flutter (12465): child: RenderDecoratedBox#4e7ca I/flutter (12465): ════════════════════════════════════════════════════════════════════════════════════════════════════ I/flutter (12465): Another exception was thrown: 'dart:ui/painting.dart': Failed assertion: line 1147: '<optimized out>': is not true. I/flutter (12465): Another exception was thrown: 'dart:ui/painting.dart': Failed assertion: line 1147: '<optimized out>': is not true. I/flutter (12465): Another exception was thrown: 'dart:ui/painting.dart': Failed assertion: line 1147: '<optimized out>': is not true. I/flutter (12465): Another exception was thrown: 'dart:ui/painting.dart': Failed assertion: line 1147: '<optimized out>': is not true. I/flutter (12465): Another exception was thrown: 'dart:ui/painting.dart': Failed assertion: line 1147: '<optimized out>': is not true.

Only when I add a cellStyle property the exception is thrown. But when I remove the property, it works.

Activity

  1. BalasubramaniSundaram commented on Oct 14, 2020

    @BalasubramaniSundaram

    Hi @dotlenter,

    Greetings from Syncfusion.

    If you want to set the text style alone for the cells, you must set the backgroundColor also with the default value. The default value can be retrieved by using the SfDataGridThemeData(brightness: Brightness.light).cellStyle.backgroundColor property.

    Please refer to the below code snippet for your reference.

    SfDataGridTheme(
      data: SfDataGridThemeData(
      ….
      cellStyle: DataGridCellStyle(
     backgroundColor:
      SfDataGridThemeData(brightness: Brightness.light)
      .cellStyle
          .backgroundColor,
      textStyle: TextStyle(fontFamily: 'HNMed'))),
      child: SfDataGrid(
      …….
      ),
    )
    

    We hope that this helps you. Please let us know if you need further assistance.

    Regards,
    Balasubramani Sundaram.

  2. dotlenter commented on Oct 15, 2020

    @dotlenter
    Author

    I see, thanks for the response, I appreciate it. But wouldn't it be better if you require the backgroundColor property for styling? It makes things clearer or set a default value or maybe even specify it in the api docs. Still thanks though for creating such plugin, great work!

  3. NeelakandanKannan commented on Nov 9, 2020

    @NeelakandanKannan

    Hi @dotlenter ,

    We have considered your feedback and included the fix in our 2020 Volume 3 SP release (18.3.47-beta) to avoid the error if any one of the property alone is set in style. Please upgrade your pub version to 18.3.47-beta to overcome that limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions