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

[Bug] PlutoGrid Unexpected null value. #88

Open
roberto-gigli opened this issue Oct 25, 2024 · 5 comments
Open

[Bug] PlutoGrid Unexpected null value. #88

roberto-gigli opened this issue Oct 25, 2024 · 5 comments
Labels
bug Something isn't working stale

Comments

@roberto-gigli
Copy link

Steps to reproduce the bug

  1. set all columns minWidth: 100,
  2. set all columns titlePadding: EdgeInsets.zero
  3. autoFit all columns when onLoaded is called
  4. horizontally scroll the grid

Expected results

Scroll horizontally

Actual results

Columns are no longer displayed and whole app does not work until restarted

Code sample

PlutoGrid(
        configuration:
            const PlutoGridConfiguration(style: PlutoGridStyleConfig.dark()),
        columns: [
          for (int i = 0; i < 30; i++)
            PlutoColumn(
              title: 'Column $i',
              field: 'column$i',
              minWidth: 100,
              type: PlutoColumnType.text(),
              titlePadding: EdgeInsets.zero,
            ),
        ],
        rows: const [],
        onLoaded: (event) {
          event.stateManager;

          for (final column in event.stateManager.columns) {
            event.stateManager.autoFitColumn(context, column);
          }
        },

Execution Environment

Flutter version
3.19.6

PlutoGrid version
8.4.0

OS
Windows 11 23H2
Web, Edge 130.0.2849.52

Video

Progetto.video.2.mp4

Logs

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following TypeErrorImpl was thrown building PlutoBaseColumn-[#17acb](state:
PlutoBaseColumnState#700c7):
Unexpected null value.

The relevant error-causing widget was:
  PlutoGrid
  PlutoGrid:file:///D:/Progetti/mw/mw-onex-supervisor-flutter/lib/view/debug/debug_view.dart:19:13

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3        throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 806:18   nullCheck
packages/flutter/src/rendering/object.dart 4137:54                                 [_debugUltimatePreviousSiblingOf]
packages/flutter/src/rendering/object.dart 4219:14                                 [_insertIntoChildList]
packages/flutter/src/rendering/object.dart 4254:5                                  insert
packages/pluto_grid_plus/src/ui/miscellaneous/pluto_visibility_layout.dart 320:17  insertRenderObjectChild
packages/flutter/src/widgets/framework.dart 6780:35                                attachRenderObject
packages/flutter/src/widgets/framework.dart 6644:5                                 mount
packages/flutter/src/widgets/framework.dart 7113:11                                mount
packages/flutter/src/widgets/framework.dart 4466:15                                inflateWidget
packages/flutter/src/widgets/framework.dart 3940:18                                updateChild
packages/flutter/src/widgets/framework.dart 5678:16                                performRebuild
packages/flutter/src/widgets/framework.dart 5817:11                                performRebuild
packages/flutter/src/widgets/framework.dart 5365:7                                 rebuild
packages/flutter/src/widgets/framework.dart 5636:5                                 [_firstBuild]
packages/flutter/src/widgets/framework.dart 5808:11                                [_firstBuild]
packages/flutter/src/widgets/framework.dart 5630:5                                 mount
packages/flutter/src/widgets/framework.dart 4466:15                                inflateWidget
packages/flutter/src/widgets/framework.dart 3940:18                                updateChild
packages/flutter/src/widgets/framework.dart 5678:16                                performRebuild
packages/flutter/src/widgets/framework.dart 5365:7                                 rebuild
packages/flutter/src/widgets/framework.dart 5636:5                                 [_firstBuild]
packages/flutter/src/widgets/framework.dart 5630:5                                 mount
packages/flutter/src/widgets/framework.dart 4466:15                                inflateWidget
packages/pluto_grid_plus/src/ui/miscellaneous/pluto_visibility_layout.dart 362:36  inflateWidget
packages/flutter/src/widgets/framework.dart 3940:18                                updateChild
packages/flutter/src/widgets/framework.dart 4141:32                                updateChildren
packages/pluto_grid_plus/src/ui/miscellaneous/pluto_visibility_layout.dart 222:17  performRebuild
packages/flutter/src/widgets/framework.dart 5365:7                                 rebuild
packages/flutter/src/widgets/framework.dart 2941:18                                buildScope
packages/flutter/src/widgets/binding.dart 989:9                                    drawFrame
packages/flutter/src/rendering/binding.dart 448:5                                  [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1386:7                                 [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1311:9                                 handleDrawFrame
packages/flutter/src/scheduler/binding.dart 1169:5                                 [_handleDrawFrame]
lib/_engine/engine/platform_dispatcher.dart 1346:5                                 invoke
lib/_engine/engine/platform_dispatcher.dart 260:5                                  invokeOnDrawFrame
lib/_engine/engine/initialization.dart 185:36                                      <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 550:37   _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 555:39   dcall
@roberto-gigli roberto-gigli added the bug Something isn't working label Oct 25, 2024
@roberto-gigli
Copy link
Author

Any news on what could cause this? This could be a make or break problem for my application

@stan-at-work
Copy link

@roberto-gigli I'm looking in to it

@stan-at-work
Copy link

stan-at-work commented Dec 6, 2024

Its fixed.

I created a PR: #106

I also added autoFitAllColumns(BuildContext context, [Iterable<PlutoColumn>? columns]) to easily auto fix all the columns.


I tested this with this example:

import 'package:flutter/material.dart';
import 'package:pluto_grid_plus/pluto_grid_plus.dart';

import '../dummy_data/development.dart';

class EmptyScreen extends StatefulWidget {
  static const routeName = 'empty';

  const EmptyScreen({super.key});

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

class _EmptyScreenState extends State<EmptyScreen> {
  late List<PlutoColumn> columns;

  late List<PlutoRow> rows;

  late PlutoGridStateManager stateManager;

  @override
  void initState() {
    super.initState();

    columns = [
      PlutoColumn(
        title: 'column1',
        field: 'column1',
        type: PlutoColumnType.text(),
      ),
      PlutoColumn(
        title: 'column2',
        field: 'column2',
        type: PlutoColumnType.text(),
      ),
      PlutoColumn(
        title: 'column3',
        field: 'column3',
        type: PlutoColumnType.text(),
      ),
    ];

    rows = DummyData.rowsByColumns(length: 10, columns: columns);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('PlutoGrid')),
      body: PlutoGrid(
        configuration:
            const PlutoGridConfiguration(style: PlutoGridStyleConfig()),
        columns: [
          for (int i = 0; i < 30; i++)
            PlutoColumn(
              backgroundColor: Colors.primaries[i % Colors.primaries.length],
              title: 'Column $i',
              field: 'column$i',
              minWidth: 100,
              type: PlutoColumnType.text(),
              titlePadding: EdgeInsets.zero,
            ),
        ],
        rows: [
          for (int i = 0; i < 5; i++)
            PlutoRow(
              cells: {
                for (int a = 0; a < 30; a++)
                  'column$a': PlutoCell(value: 'Row $a'),
              },
            ),
        ],
        onLoaded: (event) {
          for (final column in event.stateManager.columns) {
            event.stateManager.autoFitColumn(context, column);
          }
        },
      ),
    );
  }
}

@stan-at-work
Copy link

Bezig.met.opnemen.2024-12-06.181151.mp4

Copy link

github-actions bot commented Jan 6, 2025

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants