bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.

Home Page:https://pluto.weblaze.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange size bug on the 3.1.2 -> 4.0.0 transition

Macacoazul01 opened this issue · comments

There's some strange error when i transit from one of my tabs containing a pluto grid, to another that doesn't contain one. This only happens on 4.0.0.

On the first appearence of the table, everything is ok.

On the second, everything disappears(the three lines with content are visually empty):

image

Currently using flutter stable 3.0.2 on web.

Downgrading to 3.1.2 solved my problem.

Here's the log:

══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
Assertion failed:
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/visibility_detector-0.3.3/lib/src/visibility_detector.dart:203:10
..\…\src\visibility_detector.dart:203
size.width >= 0
is not true
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49  throw_
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3    assertFailed
packages/visibility_detector/src/visibility_detector.dart 203:24                                                           _area
packages/visibility_detector/src/visibility_detector.dart 155:25                                                           get visibleFraction
packages/pluto_grid/src/ui/pluto_base_column.dart 53:34                                                                    <fn>
packages/visibility_detector/src/visibility_detector_layer.dart 263:24                                                     [_fireCallback]
packages/visibility_detector/src/visibility_detector_layer.dart 234:12                                                     _processCallbacks
packages/visibility_detector/src/visibility_detector_layer.dart 171:11                                                     <fn>
packages/flutter/src/scheduler/binding.dart 1146:15                                                                        [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1091:9                                                                         handleDrawFrame
packages/flutter/src/scheduler/binding.dart 997:5                                                                          [_handleDrawFrame]
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/platform_dispatcher.dart 1090:13           invoke
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/platform_dispatcher.dart 160:5             invokeOnDrawFrame
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/initialization.dart 194:45                 <fn>

comparing pluto_base_column.dart from 3.1.2 with 4.0.0:

3.1.2:

class PlutoBaseColumn extends PlutoStatefulWidget {
  @override
  final PlutoGridStateManager stateManager;

  final PlutoColumn column;

  final double? columnTitleHeight;

  PlutoBaseColumn({
    required this.stateManager,
    required this.column,
    this.columnTitleHeight,
  }) : super(key: column.key);

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

abstract class _PlutoBaseColumnStateWithChange
    extends PlutoStateWithChange<PlutoBaseColumn> {
  bool? _showColumnFilter;

  @override
  void onChange() {
    resetState((update) {
      _showColumnFilter = update<bool?>(
        _showColumnFilter,
        widget.stateManager.showColumnFilter,
      );
    });
  }
}

class _PlutoBaseColumnState extends _PlutoBaseColumnStateWithChange {
  @override
  void initState() {
    super.initState();
    _showColumnFilter = widget.stateManager.showColumnFilter;
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      fit: StackFit.expand,
      children: [
        Positioned(
          top: 0,
          left: 0,
          right: 0,
          bottom:
              _showColumnFilter! ? widget.stateManager.columnFilterHeight : 0,
          child: PlutoColumnTitle(
            stateManager: widget.stateManager,
            column: widget.column,
            height:
                widget.columnTitleHeight ?? widget.stateManager.columnHeight,
          ),
        ),
        if (_showColumnFilter!)
          Positioned(
            bottom: 0,
            right: 0,
            left: 0,
            child: PlutoColumnFilter(
              stateManager: widget.stateManager,
              column: widget.column,
            ),
          ),
      ],
    );
  }
}

4.0.0:

class PlutoBaseColumn extends PlutoStatefulWidget {
  @override
  final PlutoGridStateManager stateManager;

  final PlutoColumn column;

  final double? columnTitleHeight;

  PlutoBaseColumn({
    required this.stateManager,
    required this.column,
    this.columnTitleHeight,
  }) : super(key: column.key);

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

abstract class _PlutoBaseColumnStateWithChange
    extends PlutoStateWithChange<PlutoBaseColumn> {
  bool? _showColumnFilter;

  @override
  void onChange(event) {
    resetState((update) {
      _showColumnFilter = update<bool?>(
        _showColumnFilter,
        widget.stateManager.showColumnFilter,
      );
    });
  }
}

class PlutoBaseColumnState extends _PlutoBaseColumnStateWithChange {
  @override
  void initState() {
    super.initState();

    VisibilityDetectorController.instance.updateInterval = Duration.zero;

    _showColumnFilter = widget.stateManager.showColumnFilter;
  }

  @override
  Widget build(BuildContext context) {
    return VisibilityDetector(
      key: widget.column.key,
      onVisibilityChanged: (info) {
        final bool visible = info.visibleFraction * 100 > 0;

        if (visible != widget.column.visible) {
          widget.column.visible = visible;

          widget.stateManager.notifyStreamListeners(
            PlutoVisibilityColumnStreamNotifierEvent(),
          );
        }
      },
      child: Stack(
        fit: StackFit.expand,
        children: [
          Positioned(
            top: 0,
            left: 0,
            right: 0,
            bottom:
                _showColumnFilter! ? widget.stateManager.columnFilterHeight : 0,
            child: PlutoColumnTitle(
              stateManager: widget.stateManager,
              column: widget.column,
              height:
                  widget.columnTitleHeight ?? widget.stateManager.columnHeight,
            ),
          ),
          if (_showColumnFilter!)
            Positioned(
              bottom: 0,
              right: 0,
              left: 0,
              child: PlutoColumnFilter(
                stateManager: widget.stateManager,
                column: widget.column,
              ),
            ),
        ],
      ),
    );
  }
}

@Macacoazul01
VisibilityDetector will be removed in the next version.

Development of an already removed version is over, but it's not yet released due to lack of testing.

I would appreciate it if you could give me the steps to reproduce it so I can test if the same problem occurs in the newer version that has been removed.

@Macacoazul01
Published 4.0.1 to the pub.
Thanks for reporting.

Gonna test tomorrow!
Tks @bosskmk