请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

运行trip_flutter主工程时报错

运行trip_flutter主工程时报错,报错日志如下:
Resolving dependencies…
Downloading packages…
carousel_slider 4.2.1 (5.0.0 available)
collection 1.18.0 (1.19.0 available)
flutter_lints 2.0.3 (4.0.0 available)
http_parser 4.0.2 (4.1.0 available)
leak_tracker 10.0.5 (10.0.7 available)
leak_tracker_flutter_testing 3.0.5 (3.0.8 available)
lints 2.1.1 (4.0.0 available)
material_color_utilities 0.11.1 (0.12.0 available)
string_scanner 1.2.0 (1.3.0 available)
test_api 0.7.2 (0.7.3 available)
Got dependencies!
10 packages have newer versions incompatible with dependency constraints.
Try flutter pub outdated for more information.
Launching lib\main.dart on sdk gphone16k x86 64 in debug mode…
Running Gradle task ‘assembleDebug’…
You are applying Flutter’s app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

You are applying Flutter’s main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
lib/widget/banner_widget.dart:2:1: Error: ‘CarouselController’ is imported from both ‘package:carousel_slider/carousel_controller.dart’ and ‘package:flutter/src/material/carousel.dart’.
import ‘package:flutter/material.dart’;
^^^^^^^^^^^^^^^^^^
lib/widget/banner_widget.dart:19:42: Error: ‘CarouselController’ is imported from both ‘package:carousel_slider/carousel_controller.dart’ and ‘package:flutter/src/material/carousel.dart’.
final CarouselController _controller = CarouselController();
^^^^^^^^^^^^^^^^^^
/C:/Users/longxl/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/carousel_slider-4.2.1/lib/carousel_slider.dart:9:1: Error: ‘CarouselController’ is imported from both ‘package:carousel_slider/carousel_controller.dart’ and ‘package:flutter/src/material/carousel.dart’.
import ‘carousel_controller.dart’;
^^^^^^^^^^^^^^^^^^
/C:/Users/longxl/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/carousel_slider-4.2.1/lib/carousel_slider.dart:48:15: Error: ‘CarouselController’ is imported from both ‘package:carousel_slider/carousel_controller.dart’ and ‘package:flutter/src/material/carousel.dart’.
: CarouselController() as CarouselControllerImpl,
^^^^^^^^^^^^^^^^^^
/C:/Users/longxl/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/carousel_slider-4.2.1/lib/carousel_slider.dart:62:15: Error: ‘CarouselController’ is imported from both ‘package:carousel_slider/carousel_controller.dart’ and ‘package:flutter/src/material/carousel.dart’.
: CarouselController() as CarouselControllerImpl,
^^^^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception

FAILURE: Build failed with an exception.

  • Where:
    Script ‘E:\LXL_WORK\DEV_ENV\flutter\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy’ line: 1687

  • What went wrong:
    Execution failed for task ‘:app:compileFlutterBuildDebug’.

Process ‘command ‘E:\LXL_WORK\DEV_ENV\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.

BUILD FAILED in 3s
Error: Gradle task assembleDebug failed with exit code 1

日志提示CarouselController 有两处重复导入,如何解决啊

正在回答 回答被采纳积分+3

2回答

宝慕林6515096 2024-10-31 18:45:53

111

0 回复 有任何疑惑可以回复我~
提问者 whitecomet 2024-09-09 23:27:36

已解决,参考https://pub.dev/packages/carousel_slider,修改pubspec.yaml的库的版本即可:

修改前:

carousel_slider: ^4.2.1

修改后:

carousel_slider: ^5.0.0

0 回复 有任何疑惑可以回复我~
  • 嗯,好的。
    回复 有任何疑惑可以回复我~ 2024-09-10 08:22:33
  • The argument type 'CarouselController' can't be assigned to the parameter type 'CarouselSliderController?'. 
    
    The method 'animateToPage' isn't defined for the type 'CarouselController'.
    Try correcting the name to the name of an existing method, or defining a method named 'animateToPage'.
    还是报错
    回复 有任何疑惑可以回复我~ 2024-10-31 18:46:15
  • 替换 CarouselController 为 CarouselSliderController
    
    controller.jumpToPage(1);  // 例如跳转到页面索引 1
    回复 有任何疑惑可以回复我~ 2024-11-04 08:58:13
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号