如何使我的Flutter和运行后`Flutter升级`?

yb3bgrhw  于 2023-06-24  发布在  Flutter
关注(0)|答案(2)|浏览(339)

我解决了我的依赖问题。
但是现在,当我试图运行项目时,我得到了所有这些错误,似乎来自Flutter libs本身。

environment:
  sdk: '>=2.18.2 <3.0.0'

我的版本:

$ flutter --version
Flutter 3.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 796c8ef792 (8 days ago) • 2023-06-13 15:51:02 -0700
Engine • revision 45f6e00911
Tools • Dart 3.0.5 • DevTools 2.23.1

flutter doctor

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.5, on macOS 12.6.2 21G320 darwin-x64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.79.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

我跑过去:

flutter clean
flutter pub get

情况却没有任何改善。
以下是报告的第一个错误。我该怎么办?

Launching lib/main.dart on Pixel 7 in debug mode...
main.dart:1
: Error: The method 'ExtendedPagePosition.copyWith' doesn't have the named parameter 'devicePixelRatio' of overridden method 'ViewportOffset with ScrollMetrics.copyWith'.
scroll_position.dart:184
  PageMetrics copyWith({
              ^
: Context: This is the overridden method ('copyWith').
scroll_position.dart:92
abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
               ^
: Error: The method 'ExtendedPagePosition.copyWith' has fewer named arguments than those of overridden method 'PageMetrics.copyWith'.
scroll_position.dart:184

  PageMetrics copyWith({
              ^
: Context: This is the overridden method ('copyWith').
page_view.dart:277
  PageMetrics copyWith({
              ^
: Error: The method 'ExtendedPagePosition.copyWith' doesn't have the named parameter 'devicePixelRatio' of overridden method 'PageMetrics.copyWith'.
scroll_position.dart:184
  PageMetrics copyWith({

              ^
: Context: This is the overridden method ('copyWith').
page_view.dart:277
  PageMetrics copyWith({
              ^
                                         ^^^^^^^^^^^
: Error: The getter 'buttonColor' isn't defined for the class 'ThemeData'.
build_color.dart:109
- 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../../flutter/packages/flutter/lib/src/material/theme_data.dart').
theme_data.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'buttonColor'.
  Color get button => Theme.of(_context).buttonColor;
                                         ^^^^^^^^^^^

: Error: Required named parameter 'devicePixelRatio' must be provided.
gesture_page_view.dart:21
final PageMetrics _testPageMetrics = PageMetrics(
                                                ^
: Context: Found this candidate, but the arguments don't match.
page_view.dart:266
  PageMetrics({
  ^^^^^^^^^^^
: Error: The superclass, 'OneSequenceGestureRecognizer with DragGestureRecognizerMixin', has no unnamed constructor that takes no arguments.
drag.dart:145
  ExtendedDragGestureRecognizer({
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: Required named parameter 'devicePixelRatio' must be provided.
scroll_position.dart:192
    return PageMetrics(
                      ^
: Context: Found this candidate, but the arguments don't match.
page_view.dart:266
  PageMetrics({

  ^^^^^^^^^^^
Target kernel_snapshot failed: Exception

...再见

3j86kqsm

3j86kqsm1#

您使用的是Flutter 3.10.5,但environment.sdk说它应该是<3.0.0
更新pubspec.yaml环境配置:

environment:
  sdk: ">=3.0.0 <4.0.0"
juzqafwq

juzqafwq2#

根据@lluchkaa的想法,我修改了sdk:

environment:
  sdk: '>=3.0.0 <4.0.0'

我用:

$ flutter clean

然后我升级了Dart:

$ dart pub upgrade

最后,我升级了我的等级,将Kotlin版本升级到最后一个稳定版本,如下所示(文件android/build.gradle):

buildscript {
    ext.kotlin_version = '1.8.22'//'1.6.10'

最终我flutter pub get编译运行,它的工作!

相关问题