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

[adaptive_scaffold] drawer stays open after selection with no way to close it #141938

Closed
rivasdiaz opened this issue Jan 20, 2024 · 6 comments
Closed
Labels
found in release: 3.16 Found to occur in 3.16 found in release: 3.19 Found to occur in 3.19 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: flutter_adaptive_scaffold The flutter_adaptive_scaffold package P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team triaged-ecosystem Triaged by Ecosystem team

Comments

@rivasdiaz
Copy link

rivasdiaz commented Jan 20, 2024

Steps to reproduce

  1. create a component using AdaptiveScaffold, leave useDrawer property unset (or set to true)
  2. run on desktop or web (as drawer is not used in mobile)
  3. make window smaller than smallBreakpoint so drawer is shown.
  4. use drawer to click any destination

Expected results

Drawer should close after clicking on a destination.

Actual results

Drawer does not close after clicking on a destination.

Although that seems the right approach for AdaptiveScaffold, it could also provide a closeDrawer method like Scaffold. Sadly, even though AdaptiveScaffold uses a Scaffold internally, using Scaffold.of(context).closeDrawer() does not work when used on onSelectedIndexChange as the Scaffold context is a child of AdaptiveScaffold and so not found on the current context inside the handler.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(App());
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => HomePageState();
}

class HomePageState extends State<HomePage> {
  
  int selectedDestination = 0;
  static const List<String> destinationLabels = <String>['Home', 'Settings'];
  
  @override
  Widget build(BuildContext context) {
    return AdaptiveScaffold(
      selectedIndex: selectedDestination,
      destinations: <NavigationDestination>[
        NavigationDestination(
          icon: const Icon(Icons.home),
          label: destinationLabels[0],
        ),
        NavigationDestination(
          icon: const Icon(Icons.settings),
          label: destinationLabels[1],
        ),
      ],
      body: (_) => Center(
        child: Text(destinationLabels[selectedDestination]),
      ),
      onSelectedIndexChange: (newDestination) {
        setState(() {
          selectedDestination = newDestination;
          // The following line does not work as parent context does not contain a scaffold
          // Scaffold.of(context).closeDrawer();
        });
      }
    );
  }
}

The example can be copied to DartPad to reproduce the bug.

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.7, on macOS 14.2.1 23C71 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.2)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!
@dam-ease dam-ease added the in triage Presently being triaged by the triage team label Jan 22, 2024
@dam-ease
Copy link

dam-ease commented Jan 22, 2024

Thanks for filing this @rivasdiaz.
I can reproduce this on the latest master and stable channels but this seems to me to be WAI and might pass as a proposal for a change instead.
I'll be labelling for more insights.

stable, master flutter doctor -v

[!] Flutter (Channel stable, 3.16.8, on macOS 14.2.1 23C71 darwin-arm64, locale
    en-NG)
    • Flutter version 3.16.8 on channel stable at
      /Users/damilolaalimi/sdks/flutter
    ! Warning: `dart` on your path resolves to
      /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/damilolaalimi/sdks/flutter.
      Consider adding /Users/damilolaalimi/sdks/flutter/bin to the front of your
      path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 67457e669f (5 days ago), 2024-01-16 16:22:29 -0800
    • Engine revision 6e2ea58a5c
    • Dart version 3.2.5
    • DevTools version 2.28.5
    • 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 34.0.0)
    • Android SDK at /Users/damilolaalimi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    • CocoaPods version 1.14.3

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

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)

[!] Android Studio (version unknown)
    • Android Studio at /Users/damilolaalimi/Downloads/Android Studio
      Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)

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

[✓] VS Code (version 1.83.1)
    • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.78.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        •
      android-arm64  • Android 14 (API 34) (emulator)
    • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E            • ios
      • iOS 17.1.1 21B91
    • iPhone 15 Pro (mobile)      • 08CB1E0F-4299-4651-AF30-498EE2040E78 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)             • macos                                •
      darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)                • chrome                               •
      web-javascript • Google Chrome 120.0.6099.234

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

! Doctor found issues in 2 categories.
[!] Flutter (Channel master, 3.19.0-9.0.pre.50, on macOS 14.2.1 23C71 darwin-arm64, locale en-NG)
    • Flutter version 3.19.0-9.0.pre.50 on channel master at /Users/damilolaalimi/fvm/versions/master
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/damilolaalimi/fvm/versions/master. Consider adding /Users/damilolaalimi/fvm/versions/master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dea6b994e (16 hours ago), 2024-01-21 12:01:23 -0500
    • Engine revision a7b207d5a1
    • Dart version 3.4.0 (build 3.4.0-52.0.dev)
    • DevTools version 2.31.0
    • 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 34.0.0)
    • Android SDK at /Users/damilolaalimi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    • CocoaPods version 1.14.3

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

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[!] Android Studio (version unknown)
    • Android Studio at /Users/damilolaalimi/Downloads/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

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

[✓] VS Code (version 1.83.1)
    • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.78.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 14 (API 34) (emulator)
    • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E            • ios            • iOS 17.1.1 21B91
    • iPhone 15 Pro (mobile)      • 08CB1E0F-4299-4651-AF30-498EE2040E78 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 120.0.6099.234

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

! Doctor found issues in 2 categories.

@dam-ease dam-ease added package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team has reproducible steps The issue has been confirmed reproducible and is ready to work on p: flutter_adaptive_scaffold The flutter_adaptive_scaffold package found in release: 3.16 Found to occur in 3.16 found in release: 3.19 Found to occur in 3.19 and removed in triage Presently being triaged by the triage team labels Jan 22, 2024
@rivasdiaz
Copy link
Author

Hi @dam-ease , thanks for your quick response.

Can I ask to please reconsider this issue as a bug instead of intended behavior? According to the material specification (both v2 and v3), modal navigation drawers can be dismissed by selecting an item (https://m3.material.io/components/navigation-drawer/guidelines#:~:text=Selecting%20a%20drawer%20item). This is not possible when using this component.

If not, thanks for leaving it as a proposal.

@stuartmorgan stuartmorgan added P3 Issues that are less important to the Flutter project triaged-ecosystem Triaged by Ecosystem team labels Jan 23, 2024
@aliasgar4558
Copy link
Contributor

I agree - We can have a bug fix to dismiss drawer in case of already open for that specific Scaffold. Apparently, I will try to add some fix into this one & lets see how that goes.

auto-submit bot pushed a commit to flutter/packages that referenced this issue Mar 21, 2024
…on tap. (#6289)

(#141938)

*Changes included in PR are listed as follows*

- As per material guidelines, Drawer shall be dismissed when user taps any destination/item. If drawer is open, and user taps on any item, before calling onDestinationSelected() - we are now dismissing drawer.
- CHANGELOG.md file updated.
- Updated to v0.1.9.

*Issue : flutter/flutter#141938
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Mar 21, 2024
auto-submit bot pushed a commit that referenced this issue Mar 21, 2024
flutter/packages@23e56af...b7fbe68

2024-03-21 38110731+aliasgar4558@users.noreply.github.com [adaptive_scaffold] : � #141938 - Drawer stays open even on destination tap. (flutter/packages#6289)
2024-03-20 43054281+camsim99@users.noreply.github.com [camera_android] Update README to encourage users to use CameraX implementation (flutter/packages#6353)
2024-03-20 engine-flutter-autoroll@skia.org Roll Flutter from d31a85b to b96c13d (19 revisions) (flutter/packages#6359)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@aliasgar4558
Copy link
Contributor

Fix added, we can close the issue.

@aliasgar4558
Copy link
Contributor

@rivasdiaz - Can we please mark this issue as fixed/closed as fix has been deployed & available to users.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
found in release: 3.16 Found to occur in 3.16 found in release: 3.19 Found to occur in 3.19 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: flutter_adaptive_scaffold The flutter_adaptive_scaffold package P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team triaged-ecosystem Triaged by Ecosystem team
Projects
None yet
Development

No branches or pull requests

4 participants