jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.26k stars 1.61k forks source link

BottomSheet. CurrentRoute problem #1751

Closed Auramel closed 3 years ago

Auramel commented 3 years ago

When I open BottomSheet and use Get.toNamed with await currentRoute is not correct. So, when I clicked second time, nothing happening.

  1. Click on button with 'Click me'.
  2. Click on button in bottomSheet 'Move to page2'.
  3. Click backbutton.
  4. Look in logs.

Logs

Restarted application in 314ms.
[GETX] Instance "GetMaterialController" has been created
[GETX] Instance "GetMaterialController" has been initialized
[GETX] GOING TO ROUTE /
[GETX] OPEN BOTTOMSHEET 736390997
flutter: /
[GETX] GOING TO ROUTE /two
[GETX] CLOSE TO ROUTE /two
flutter: /two

Code

import 'package:flutter/material.dart';
import 'package:get/get.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      initialRoute: '/',
      getPages: [
        GetPage(
          name: '/',
          page: () => FirstPage(),
        ),
        GetPage(
          name: '/two',
          page: () => SecondPage(),
        ),
      ],
    );
  }
}

class FirstPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('First page'),
      ),
      body: Center(
        child: ElevatedButton(
          child: Text('Click me'),
          onPressed: () {
            Get.bottomSheet(
              Container(
                height: double.infinity,
                color: Colors.white,
                child: ElevatedButton(
                  onPressed: () async {
                    print(Get.currentRoute);
                    await Get.toNamed('/two');
                    print(Get.currentRoute);
                  },
                  child: Text('Move to page 2'),
                ),
              ),
            );
          },
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Second page'),
      ),
    );
  }
}

GetX

get:
    dependency: "direct main"
    description:
      name: get
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.3.6"

flutter doctor -v

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale
    ru-RU)
    • Flutter version 2.2.3 at /opt/homebrew/Caskroom/flutter/2.2.3/flutter
    • Framework revision f4abaa0735 (6 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/auramel/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at
    /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 4.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 11.0.8+10-b944.6916264)

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

[✓] Connected device (1 available)
    • iPhone 12 Pro Max (mobile) • F719D910-043C-4BF3-AB2B-5A61170CEFD1 • ios •
      com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)

! Doctor found issues in 2 categories.
jonataslaw commented 3 years ago

I think this is a duplicate of:

https://github.com/jonataslaw/getx/issues/1742

There is already a hotfix ready, and it will be released today

Auramel commented 3 years ago

I think this is a duplicate of:

1742

There is already a hotfix ready, and it will be released today

thanks!

jonataslaw commented 3 years ago

Fixed on get 4.3.7

kailaisi commented 3 years ago

I think this is a issues not fixed. The valute.current means the current PageRoute .But in this case , the value.current is a sheetRoute name .

CodeIdeal commented 2 years ago

Same issue in 4.3.8. It doesn't look like it's been fixed.

Here's a workaround, set preventDuplicates=false.

wangyujie1207 commented 2 years ago

Same issue in 4.3.8. It doesn't look like it's been fixed.

Here's a workaround, set preventDuplicates=false.

same issue in 4.6.1