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

🐛 Widget Inspector throws error on TreeView #974

Closed
pamtbaau opened this issue Nov 22, 2023 · 1 comment
Closed

🐛 Widget Inspector throws error on TreeView #974

pamtbaau opened this issue Nov 22, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@pamtbaau
Copy link

pamtbaau commented Nov 22, 2023

Describe the bug
A clear and concise description of what the bug is.

When showing a TreeView, the Widget Inspector throw an error

To Reproduce
Steps to reproduce the behavior:

  • Create a default Windows desktop app
  • Add fluent_ui as dependency
    dependencies:
      flutter:
        sdk: flutter
    
      fluent_ui:
        git: https://github.com/bdlukaa/fluent_ui.git
    
  • Use the following main.dart
    import 'package:fluent_ui/fluent_ui.dart';
    
    void main() {
      WidgetsFlutterBinding.ensureInitialized();
    
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return FluentApp(
          title: 'Flutter Demo',
          home: NavigationView(
            pane: NavigationPane(
              selected: 1,
              displayMode: PaneDisplayMode.compact,
              items: [
                PaneItem(
                  icon: const Icon(FluentIcons.dashboard_add),
                  title: const Text('TreeView test'),
                  body: const MyHomePage(),
                ),
              ],
            ),
          ),
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      const MyHomePage({super.key});
    
      @override
      Widget build(BuildContext context) {
        return TreeView(
          items: [
            _createTagTree(),
          ],
        );
      }
    
      TreeViewItem _createTagTree() {
        return TreeViewItem(
          expanded: true,
          content: const Text('root'),
          value: null,
          selected: false,
          children: [
            TreeViewItem(
              expanded: true,
              content: const Text('Tag 1'),
              value: 1,
              selected: false,
              children: [],
            ),
            TreeViewItem(
              expanded: true,
              content: const Text('Tag 2'),
              value: 2,
              selected: false,
              children: [],
            ),
            TreeViewItem(
              expanded: true,
              content: const Text('Tag 2'),
              value: 3,
              selected: false,
              children: [],
            ),
          ],
        );
      }
    }
    
  • In VScode, open Widget Inspector
    • No widget tree is shown in Inspector

    • Error is thrown in Debug Console

      The following assertion was thrown during a service extension callback for "ext.flutter.inspector.getRootWidgetSummaryTreeWithPreviews":
      'package:flutter/src/foundation/diagnostics.dart': Failed assertion: line 2091 pos 15: 'ifTrue != null || ifFalse != null': is not true.

      When the exception was thrown, this was the stack:
      #2 new FlagProperty (package:flutter/src/foundation/diagnostics.dart:2091:15) diagnostics.dart:2091
      #3 TreeView.debugFillProperties (package:fluent_ui/src/controls/navigation/tree_view.dart:655:13) tree_view.dart:655
      #4 etc.

Expected behavior
I would expect to see a widget tree inside the Widget Inspector

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@bdlukaa bdlukaa added the bug Something isn't working label Nov 25, 2023
@pamtbaau
Copy link
Author

Thanks, it's working!

Question though...

  • Shouldn't the children of a TreeView be a TreeViewItem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants