stryder-dev / flutter_platform_widgets

Target the specific design of Material for Android and Cupertino for iOS widgets through a common set of Platform aware widgets
MIT License
1.59k stars 174 forks source link

Opening showBottomSheet from inside PlatformScaffold #434

Closed nissaba closed 1 year ago

nissaba commented 1 year ago

I am getting this exception when pressing a button to open a bottomSheet

======== Exception caught by gesture =============================================================== The following assertion was thrown while handling a gesture: No Scaffold widget found.

CreateAccountView widgets require a Scaffold widget ancestor. The specific widget that could not find a Scaffold ancestor was: CreateAccountView dependencies: [MediaQuery] state: _CreateAccountViewState#46a67 The ancestors of this widget were: : PlatformApp dependencies: [_InheritedTheme] : PlatformTheme state: _PlatformThemeState#080d1 : PlatformProvider state: _PlatformProviderState#19eea : MyApp ...

Typically, the Scaffold widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree.

This my code:

main .. runnapp(MyApp()) .. 
    MyApp .. 
       PlatformProvider ...
          home: HomeView ...
            PlatformScaffold ...
             body: (View pushing to a new View) ...
               CreateAccountView...
                 PlatformScaffold ...
                   body: .....
                     TextButton(
                      style: ButtonStyle(
                        backgroundColor: MaterialStateProperty.all<Color>(Colors.grey),
                        padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.all(10)),
                      ),
                      onPressed: () {
                        showBottomSheet(
                          context: context,
                          builder: (context) {
                            return const Center(child: UserAgreementsView());
                          },
                        );
                      },
                      child: const Text(
                        'View user agreements',
                        style: TextStyle(color: Colors.black),
                      ),
                    )
     .......

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d darwin-arm64, locale fr-CA) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] Android Studio (version 2022.1) [✓] VS Code (version 1.80.0) [✓] Connected device (3 available) [✓] Network resources

flutter_platform_widgets: ^3.3.5

nissaba commented 1 year ago

showModalBottomSheet does work, using this as a work around.