skip to Main Content

I build a flutter app but run into error
enter image description here

/C:/Users/david.huang/AppData/Local/Pub/Cache/hosted/pub.dev/sync_scroll_library-1.0.1/lib/src/gesture/gesture_state_mixin.dart:6:49: Error: Required named parameter 'devicePixelRatio' must be provided.
final PageMetrics _testPageMetrics = PageMetrics(
                                                ^
/C:/flutter/packages/flutter/lib/src/widgets/page_view.dart:266:3: Context: Found this candidate, but the arguments don't match.
  PageMetrics({
  ^^^^^^^^^^^
Failed to compile application.

The widget PageMetrics is Flutter SDK original widget so I cant modify it

I have tried invalidate Caches and restart but still not work.

Has anyone also encountered this problem?

How to solve it?

2

Answers


  1. I had this same issue after updating to the latest version of flutter on the master channel. The devicePixelRatio argument was changed to required in the latest version, so one of my packages that was using it was no longer compatible. In my case it was the material_floating_search_bar package, I ended up just dropping the package as I no longer needed it. For you, you probably need to update to the latest sync_scroll_library. If that is still incompatible you may need to either drop the library, create an issue and/or a PR for the library to get it updated, or use an earlier version of flutter for the time being.

    Login or Signup to reply.
  2. I tried in Android Studio > External Libraries > Dart Packages > sync_scroll_library-1.0.1 > src > gesture > gesture_state_mixin.dart
    to make
    final PageMetrics _testPageMetrics = PageMetrics( axisDirection: AxisDirection.down, minScrollExtent: 0, maxScrollExtent: 10, pixels: 5, viewportDimension: 10, viewportFraction: 1.0, devicePixelRatio:1.0 // add this line ); and solved the problem.
    Maybe that will help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search