flutter icon indicating copy to clipboard operation
flutter copied to clipboard

Flutter 3.7.0: Modal bottom sheet Issue

Open varenaya opened this issue 1 year ago • 2 comments

I tried to run my application in debug mode after upgrading to flutter 3.7.0 from 3.3.9, but was unable to build it due to this issue.

Launching lib\main.dart on sdk gphone x86 in debug mode...
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart:101:13: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
      .push(ModalBottomSheetRoute<T>(
            ^^^^^^^^^^^^^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart:124:10: Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'.
 - 'Object' is from 'dart:core'.
 - 'Future' is from 'dart:async'.
  return result;
         ^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart:28:13: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
      .push(ModalBottomSheetRoute<T>(
            ^^^^^^^^^^^^^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart:50:10: Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'.      
 - 'Object' is from 'dart:core'.
 - 'Future' is from 'dart:async'.
  return result;
         ^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/material_with_modal_page_route.dart:4:1: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
import '../modal_bottom_sheet.dart';
^^^^^^^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Running Gradle task 'assembleDebug'...                              7.4s
Exception: Gradle task assembleDebug failed with exit code 1

Output for flutter doctor -v

[√] Flutter (Channel stable, 3.7.0, on Microsoft Windows [Version 10.0.22621.1105], locale en-IN)
    • Flutter version 3.7.0 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (3 days ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1

[√] 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\varen\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
    • All Android licenses accepted.

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

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.6)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.2.32630.192
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.1)
    • 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.11+9-b60-7590822)

[√] VS Code (version 1.74.3)
    • VS Code at C:\Users\varen\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.58.0

[√] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.1105]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 109.0.5414.75
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 109.0.1518.61

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

• No issues found!

varenaya avatar Jan 26 '23 14:01 varenaya

I think you could solve this by adding hide ModalBottomSheetRoute to the import of either package:flutter/material.dart or package:modal_bottom_sheet/modal_bottom_sheet.dart.

savadodesigns avatar Jan 26 '23 14:01 savadodesigns

@savadodesigns

I think you could solve this by adding hide ModalBottomSheetRoute to the import of either package:flutter/material.dart or package:modal_bottom_sheet/modal_bottom_sheet.dart.

tried this but doesn't really work had this same issue in flutter 3.7 beta too. Also i am only importing package:flutter/material.dart i guess this issue persists with the sdk.

varenaya avatar Jan 26 '23 14:01 varenaya

If you'd like some further info, there's the PR that made this change in flutter

https://github.com/flutter/flutter/pull/108112

As well as some relevant issues in package:modal_bottom_sheet/modal_bottom_sheet.dart

#284 #291

There are also at least 4 PRs on the package:modal_bottom_sheet/modal_bottom_sheet.dart repo that you can take a look at

#307 #313 #315 #316

saltedpotatos avatar Jan 26 '23 18:01 saltedpotatos

Hi @varenaya The issue is related to a 3rd party plugin (modal_bottom_sheet) rather than to Flutter itself. Please open the issue in the dedicated repository.

For quick search results, I see there is an existing issue addressing the case you described https://github.com/jamesblasco/modal_bottom_sheet/issues/314, so please follow up on it for further updates.

Closing, as this isn't an issue with Flutter itself.

huycozy avatar Jan 27 '23 03:01 huycozy

If you'd like some further info, there's the PR that made this change in flutter

#108112

As well as some relevant issues in package:modal_bottom_sheet/modal_bottom_sheet.dart

#284 #291

There are also at least 4 PRs on the package:modal_bottom_sheet/modal_bottom_sheet.dart repo that you can take a look at

#307 #313 #315 #316

yeah this was helpful, i happen to be using few packages that were using package:modal_bottom_sheet/modal_bottom_sheet.dart, also found the solution for that too.

varenaya avatar Jan 27 '23 04:01 varenaya

I am new to this can you also helm me in this issue, i am trying to build apk but keep getting this error

../../../../../.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/material_with_modal_page_route.dart:4:1: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'. import '../modal_bottom_sheet.dart';

shaikhemran79 avatar Feb 01 '23 07:02 shaikhemran79

I am new to this can you also helm me in this issue, i am trying to build apk but keep getting this error

../../../../../.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/material_with_modal_page_route.dart:4:1: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'. import '../modal_bottom_sheet.dart';

This is because of the packages you are using in your code which happen to use package:modal_bottom_sheet/modal_bottom_sheet.dart and are not optimize for flutter 3.7.0, hence try to find the packages responsible, upgrade them if their updates are available or downgrade your flutter version.

varenaya avatar Feb 01 '23 09:02 varenaya

thanks, as of ow i bypassed the error by this

dependency_overrides: modal_bottom_sheet: git: url: https://github.com/danReynolds/modal_bottom_sheet.git path: modal_bottom_sheet

shaikhemran79 avatar Feb 01 '23 12:02 shaikhemran79

I solved this issue by using their pre-release update modal_bottom_sheet: ^3.0.0-pre

Hope this helps

Milimeter avatar Feb 03 '23 08:02 Milimeter

Funcionou pra mim, muito obrigado!

Trindade15 avatar Feb 06 '23 14:02 Trindade15

So this is the only way..

dependency_overrides:
  modal_bottom_sheet: ^3.0.0-pre 

ch-muhammad-adil avatar Feb 13 '23 10:02 ch-muhammad-adil

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[bot] avatar Mar 03 '23 08:03 github-actions[bot]