Skip to content

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

Closed
flutter/packages
#9103

Description

@yahooooza

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!

Activity

  1. darshankawar commented on May 29, 2024

    @darshankawar
    Member

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

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 29, 2024
  3. yahooooza commented on May 29, 2024

    @yahooooza
    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".

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 29, 2024
  5. darshankawar commented on May 29, 2024

    @darshankawar
    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.
    
    
    
    
  6. added
    packageflutter/packages repository. See also p: labels.
    p: two_dimensional_scrollablesIssues pertaining to the two_dimensional_scrollables package
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on May 29, 2024
  7. added
    P2Important issues not at the top of the work list
    on Jun 4, 2024
  8. 1 remaining item

  9. MichelleWeck commented on Mar 6, 2025

    @MichelleWeck

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

  10. added
    r: fixedIssue is closed as already fixed in a newer version
    on May 2, 2025
  11. github-actions commented on May 16, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  12. locked as resolved and limited conversation to collaborators on May 16, 2025
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

    P2Important issues not at the top of the work lista: desktopRunning on desktopfound in release: 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: two_dimensional_scrollablesIssues pertaining to the two_dimensional_scrollables packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flight

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions