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

Best way to handle onTap in DrawerOption to change Widget #49

Open
tsquillario opened this issue Mar 13, 2023 · 1 comment
Open

Best way to handle onTap in DrawerOption to change Widget #49

tsquillario opened this issue Mar 13, 2023 · 1 comment

Comments

@tsquillario
Copy link

tsquillario commented Mar 13, 2023

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
@FilledStacks
Copy link
Owner

Hey, I've never had problem changing state based on tap so I don't quite know what the issue it. I would have a value in the viewmodel that tells me what state the UI should be in and I'll change that state on tap, call rebuildUi and then the state should rebuild with the new UI in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants