FilledStacks / FilledStacks/responsive_builder

Best way to handle onTap in DrawerOption to change Widget

Open
#49 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
524
Forks
90
PR merge metrics
No merged PRs in 30d

Description

What's the best way to handle the `onTap` event from `DrawerOption` to change the Widget in the `HomeView` pages?

I was able to get it working using a `StreamBuilder` that is listening on the `home_view_mobile.dart` and `home_view_tablet.dart` pages. Then in `drawer_option.dart` I added an `InkWell` with the `onTap` event adding events to the stream. Is this the best way? It works but when I add a `TextField` the `FutureBuilder` is reloading due to the rebuild of the page when the keyboard opens. I changed the future to be in `initState` and while that usually works it didn't here and I found out it was because of the `StreamBuilder`. Thoughts?

My current workaround is changing the `onTap` to navigate to the page instead of changing out the widget. Now the `AppDrawer` isn't shown.

https://stackoverflow.com/questions/73330084/there-is-a-problem-that-is-rebuild-when-i-click-textfield-in-flutter

```
[!] Flutter (Channel @upstream, 3.7.3, on Microsoft Windows [Version 10.0.19044.2604], locale en-US)
• Flutter version 3.7.3 on channel @upstream at C:\src\flutter
! Unknown upstream repository.
Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
• Framework revision 9944297138 (5 weeks ago), 2023-02-08 15:46:04 -0800
• Engine revision 248290d6d5
• Dart version 2.19.2
• DevTools version 2.20.1
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\tsqui\AppData\Local\Android\Sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = C:\Users\tsqui\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.20)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
• Visual Studio Build Tools 2019 version 16.11.32929.386
• Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.3)
• Android Studio at C:\Program Files\Android\Android Studio
• 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 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.76.1)
• VS Code at C:\Users\tsqui\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.60.0

[√] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.2604]
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5481.178
• Edge (web) • edge • web-javascript • Microsoft Edge 110.0.1587.69

[√] HTTP Host Availability
• All required HTTP hosts are available
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.