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

πŸ› The PaneItemExpander doesn't work normal #959

Closed
H2Sxxa opened this issue Nov 7, 2023 · 1 comment
Closed

πŸ› The PaneItemExpander doesn't work normal #959

H2Sxxa opened this issue Nov 7, 2023 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@H2Sxxa
Copy link
Contributor

H2Sxxa commented Nov 7, 2023

Describe the bug

The PaneItemExpander doesn't work normal.

════════ Exception caught by widgets library ═══════════════════════════════════
The following _TypeError was thrown building _PaneItemExpander-[LabeledGlobalKey<__PaneItemExpanderState>#18916](dirty, dependencies: [_FluentTheme, _InheritedNavigationView], state: __PaneItemExpanderState#fd9cf):
Null check operator used on a null value

The relevant error-causing widget was
_PaneItemExpander-[LabeledGlobalKey<__PaneItemExpanderState>#18916]
pane_items.dart:629
When the exception was thrown, this was the stack
#0      __PaneItemExpanderState.build
pane_items.dart:807
#1      StatefulElement.build
framework.dart:5409
#2      ComponentElement.performRebuild
framework.dart:5297
#3      StatefulElement.performRebuild
framework.dart:5462
#4      Element.rebuild
framework.dart:5016
#5      ComponentElement._firstBuild
framework.dart:5279
#6      StatefulElement._firstBuild
framework.dart:5453
#7      ComponentElement.mount
framework.dart:5273
...     Normal element mounting (47 frames)
#54     Element.inflateWidget
framework.dart:4182
#55     Element.updateChild
framework.dart:3707
#56     SliverMultiBoxAdaptorElement.updateChild
sliver.dart:857
#57     SliverMultiBoxAdaptorElement.createChild.<anonymous closure>
sliver.dart:842

To Reproduce

import 'package:fluent_ui/fluent_ui.dart';

void main() {
  runApp(const Demo());
}

class Demo extends StatelessWidget {
  const Demo({super.key});

  @override
  Widget build(BuildContext context) {
    return FluentApp(
        title: 'Flutter Demo',
        home: NavigationView(
          pane: NavigationPane(items: [
            PaneItem(
                title: const Text("Test"),
                icon: const Icon(FluentIcons.accept),
                body: ScaffoldPage.scrollable(
                    children: const [Text("Hello world")])),
            PaneItemSeparator(),
            PaneItemExpander(
                icon: const Icon(FluentIcons.toolbox),
                items: [],
                body: const Text("Expander"))
          ]),
        ));
  }
}

Expected behavior

The Expander should not crash here.

Screenshots

image

Additional context

Version

fluent_ui: ^4.7.7

Flutter Docker

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.13.9, on Microsoft Windows [η‰ˆζœ¬ 10.0.22635.2700], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.3)
[!] Android Studio (not installed)
[√] VS Code (version 1.84.1)
[√] Connected device (2 available)
[√] Network resources

! Doctor found issues in 3 categories.
@H2Sxxa H2Sxxa changed the title πŸ› The PaneItemExpander doesn't work normal πŸ› The PaneItemExpander doesn't work normal Nov 7, 2023
@bdlukaa bdlukaa added the bug Something isn't working label Nov 9, 2023
@H2Sxxa
Copy link
Contributor Author

H2Sxxa commented Dec 13, 2023

Hello! I solved now

PaneItemExpander must have a not empty item list and the selected of NavigationPane must be not null.

I think there should have a more clear exception info, like assert(body.pane!.selected != null, "The selected of NavigationPane can not be null!"); in the build Function.

Code

import 'package:fluent_ui/fluent_ui.dart';

void main() {
  runApp(const Demo());
}

class Demo extends StatelessWidget {
  const Demo({super.key});

  @override
  Widget build(BuildContext context) {
    return FluentApp(
        title: 'Flutter Demo',
        home: NavigationView(
          pane: NavigationPane(selected: 0, items: [
            PaneItem(
                title: const Text("Test"),
                icon: const Icon(FluentIcons.accept),
                body: ScaffoldPage.scrollable(
                    children: const [Text("Hello world")])),
            PaneItemSeparator(),
            PaneItemExpander(
                icon: const Icon(FluentIcons.toolbox),
                items: [
                  PaneItem(
                      title: const Text("Test"),
                      icon: const Icon(FluentIcons.accept),
                      body: ScaffoldPage.scrollable(
                          children: const [Text("Hello world 2")])),
                ],
                body: const Text("Expander"))
          ]),
        ));
  }
}

image

@bdlukaa bdlukaa added the documentation Improvements or additions to documentation label Dec 13, 2023
@H2Sxxa H2Sxxa closed this as completed Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants