skip to Main Content

I solved the dependency issues I had.

But now, when trying to run the project I get all those errors that seem to come from Flutter libs themselves.


environment:
  sdk: '>=2.18.2 <3.0.0'

My version:

$ 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

And the 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!

I ran:

flutter clean
flutter pub get

without any improvement about the situation.

Here are the first error reported. What should I do?

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

…and so long.

2

Answers


  1. Chosen as BEST ANSWER

    Following up @lluchkaa idea, I changed the sdk:

    environment:
      sdk: '>=3.0.0 <4.0.0'
    

    And, I did clean with:

    $ flutter clean
    

    Then I upgraded Dart with:

    $ dart pub upgrade
    

    And, finally, I upgraded my grade, by bumping Kotlin version to the last stable as follows (file android/build.gradle):

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

    Eventually I flutter pub getand compiled and run, and it works!


  2. You’re using Flutter 3.10.5, but environment.sdk says it should be <3.0.0.

    Update the pubspec.yaml environment config:

    environment:
      sdk: ">=3.0.0 <4.0.0"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search