Skip to content

[two_dimensional_scrollables] TreeView Widget blanks when closing last parent #149182

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

Open
yahooooza opened this issue May 28, 2024 · 4 comments · May be fixed by flutter/packages#9103
Open

[two_dimensional_scrollables] TreeView Widget blanks when closing last parent #149182

yahooooza opened this issue May 28, 2024 · 4 comments · May be fixed by flutter/packages#9103
Labels
a: desktop Running on desktop found in release: 3.22 Found to occur in 3.22 found in release: 3.23 Found to occur in 3.23 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. team-framework Owned by Framework team triaged-framework Triaged by Framework team waiting for PR to land (fixed) A fix is in flight

Comments

@yahooooza
Copy link

yahooooza commented May 28, 2024

Steps to reproduce

  1. Open a TreeView such that all Elements exceeds screensize height
  2. Scroll down to the latest Item. This Item should be a parent of other items
  3. Open the item and then close it.

Failure is also reproducable with the given example from the library.

Tested on Linux and Windows

Expected results

The item should close normally.

Actual results

The whole tree disappears and i get the following exception. After scrolling up and down the tree reappears.

The following _TypeError was thrown during paint():
Null check operator used on a null value

The relevant error-causing widget was: 
  TreeView<WorkPackage> TreeView:file:///<projectpathfile>
When the exception was thrown, this was the stack: 
#0      RenderTreeViewport._paintRows (package:two_dimensional_scrollables/src/tree_view/render_tree.dart:594:8)
#1      RenderTreeViewport.paint.<anonymous closure> (package:two_dimensional_scrollables/src/tree_view/render_tree.dart:422:13)
#2      PaintingContext.pushLayer (package:flutter/src/rendering/object.dart:486:12)
#3      PaintingContext.pushClipRect (package:flutter/src/rendering/object.dart:546:7)
#4      RenderTreeViewport.paint (package:two_dimensional_scrollables/src/tree_view/render_tree.dart:417:57)
#5      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3239:7)
#6      PaintingContext._repaintCompositedChild (package:flutter/src/rendering/object.dart:166:11)
#7      PaintingContext.repaintCompositedChild (package:flutter/src/rendering/object.dart:109:5)

Code sample

Code sample
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

import 'custom_tree.dart';
import 'simple_tree.dart';

/// The page containing the interactive controls that modify the sample
/// TreeView.
class TreeExplorer extends StatefulWidget {
  /// Creates a screen that demonstrates the TreeView widget in varying
  /// configurations.
  const TreeExplorer({super.key});

  @override
  State<TreeExplorer> createState() => _TreeExplorerState();
}

/// Which example is being displayed.
enum TreeType {
  /// Displays TreeExample.
  simple,

  /// Displays CustomTreeExample.
  custom,
}

class _TreeExplorerState extends State<TreeExplorer> {
  final SizedBox _spacer = const SizedBox.square(dimension: 20.0);
  TreeType _currentExample = TreeType.simple;
  String _getTitle() {
    return switch (_currentExample) {
      TreeType.simple => 'Simple TreeView',
      TreeType.custom => 'Customizing TreeView',
    };
  }

  Widget _getTree() {
    return switch (_currentExample) {
      TreeType.simple => const TreeExample(),
      TreeType.custom => const CustomTreeExample(),
    };
  }

  Widget _getRadioRow() {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        children: <Widget>[
          const Spacer(),
          Radio<TreeType>(
            value: TreeType.simple,
            groupValue: _currentExample,
            onChanged: (TreeType? value) {
              setState(() {
                _currentExample = value!;
              });
            },
          ),
          const Text('Simple'),
          _spacer,
          Radio<TreeType>(
            value: TreeType.custom,
            groupValue: _currentExample,
            onChanged: (TreeType? value) {
              setState(() {
                _currentExample = value!;
              });
            },
          ),
          const Text('Custom'),
          const Spacer(),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(_getTitle()),
        bottom: PreferredSize(
          preferredSize: const Size.fromHeight(50),
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: _getRadioRow(),
          ),
        ),
      ),
      body: _getTree(),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
2024-05-28.17-00-23.mp4
treeview.2024-05-28.17-11-15.mp4

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.1, on Manjaro Linux 6.8.9-3-MANJARO, locale de_DE.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.3)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label May 29, 2024
@darshankawar
Copy link
Member

@yahooooza Can you provide us a runnable reproducible code sample that triggers the reported log ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 29, 2024
@yahooooza
Copy link
Author

@darshankawar As already mentioned, the beaviour appears also in the given example from the library. I update the issue with the example code form the repo. You can see the beaviour in the second video i posted under "Screenshots or Video".

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 29, 2024
@darshankawar
Copy link
Member

Thanks for the update. Using the code sample provided and running on desktop, I was able to replicate the reported error.

stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.22.0, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 3.22.0 on channel stable at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (5 days ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

[!] Flutter (Channel master, 3.23.0-12.0.pre.7, on macOS 12.2.1 21D62
    darwin-x64, locale en-GB)
    • Flutter version 3.23.0-12.0.pre.7 on channel master at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35ae519140 (2 hours ago), 2024-05-29 00:33:07 -0400
    • Engine revision b26e1b023c
    • Dart version 3.5.0 (build 3.5.0-191.0.dev)
    • DevTools version 2.36.0-dev.10
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/dhs/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 65.1.4
    • Dart plugin version 213.7228

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (3 available)
    • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
      • iOS 15.3.1 19D52
    • macOS (desktop)           • macos                                    •
      darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)              • chrome                                   •
      web-javascript • Google Chrome 109.0.5414.119

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
      
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.



@darshankawar darshankawar added package flutter/packages repository. See also p: labels. p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.22 Found to occur in 3.22 found in release: 3.23 Found to occur in 3.23 a: desktop Running on desktop team-framework Owned by Framework team and removed in triage Presently being triaged by the triage team labels May 29, 2024
@goderbauer goderbauer added P2 Important issues not at the top of the work list triaged-framework Triaged by Framework team labels Jun 4, 2024
@MichelleWeck
Copy link

This problem is still reproducable in the newest Flutter version, 3.29.0. Will there be a fix to this issue?

tdenniston added a commit to tdenniston/packages that referenced this issue Apr 17, 2025
Collapsing a node when there were other nodes offscreen was causing an
unexpected null dereference during painting. This PR fixes the bug and
adds a test.

The bug was caused by erroneous computation of the max vertical scroll
extent. Previously, the code computed this considering only scroll
extent in the trailing (down) direction; it may also be the case that
there is a larger scroll extent in the leading (up) direction.

The miscalculation resulted in subsequent error computing the first
visible row as a row that is actually offscreen, and thus does not have
a render box. The row render box is asserted to be non-null during
painting.

Fixes flutter/flutter#149182
Fixes flutter/flutter#164981
tdenniston added a commit to tdenniston/packages that referenced this issue Apr 17, 2025
Collapsing a node when there were other nodes offscreen was causing an
unexpected null dereference during painting. This PR fixes the bug and
adds a test.

The bug was caused by erroneous computation of the max vertical scroll
extent. Previously, the code computed this considering only scroll
extent in the trailing (down) direction; it may also be the case that
there is a larger scroll extent in the leading (up) direction.

The miscalculation resulted in subsequent error computing the first
visible row as a row that is actually offscreen, and thus does not have
a render box. The row render box is asserted to be non-null during
painting.

Fixes flutter/flutter#149182 and
flutter/flutter#164981
@Piinks Piinks added the waiting for PR to land (fixed) A fix is in flight label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop found in release: 3.22 Found to occur in 3.22 found in release: 3.23 Found to occur in 3.23 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. team-framework Owned by Framework team triaged-framework Triaged by Framework team waiting for PR to land (fixed) A fix is in flight
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants