由于依赖冲突而模拟时出错

问题描述 投票:0回答:1

我需要帮助。当我模拟我的应用程序时,出现以下错误。我能做什么?

Launching lib\main.dart on SM A032M in debug mode...
../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart:102: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:125: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.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\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 41s
Exception: Gradle task assembleDebug failed with exit code 1

Exited (1).

进口

import 'dart:convert';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:weather/components/weather_item.dart';
import 'package:weather/constants.dart';
import 'package:weather/ui/detail_page.dart';

import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';

由于我只安装了该依赖项,并且它给了我这个错误,我该怎么办? 在这种情况下我可以做什么来解决这个问题?

flutter dependencies flutter-dependencies
1个回答
0
投票

好吧,有混乱,因为你导入的包或文件的名称为

ModalBottomSheetRoute<T>
我不知道这段代码的上下文,但试试这个:

import 'dart:convert';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:weather/components/weather_item.dart';
import 'package:weather/constants.dart';
import 'package:weather/ui/detail_page.dart';

import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart' as modalSheet;

当从包类型中使用它时:

modalsheet.code

© www.soinside.com 2019 - 2024. All rights reserved.