In my bottom_nav_layout package, I am losing 10 pub points because of the dart formatting. pub.dev says:
"lib/src/page_stack.dart doesn't match the Dart formatter."
The error message can be found here. However, when I run dart format .
or flutter format .
, the offending file is not changed.
"... Unchanged lib\src\page_stack.dart ..."
How to solve this problem?
flutter doctor:
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.985], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.62.2)
[√] Connected device (3 available)
CodePudding user response:
The Dart formatter changed the rules for cascades in Dart 2.14 with the following change which makes the formatter to always split the cascade in case of multiple cascades: https://github.com/dart-lang/dart_style/issues/1006
This explains why there are a difference in how your code is formatted when using Dart 2.13 (or older) comparing to latest version (Dart 2.14.x).
So if you want the maximum of points on pub.dev, you need to use Dart 2.14 or later, to do the formatting, since pub.dev are using the new formatting rules for cascades when checking if your code is well-formatted.