Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running under Dart 2.18/Flutter 3.3 #1

Closed
hyiso opened this issue Feb 28, 2023 · 6 comments
Closed

Running under Dart 2.18/Flutter 3.3 #1

hyiso opened this issue Feb 28, 2023 · 6 comments
Labels
bug Something isn't working compatibility

Comments

@hyiso
Copy link
Owner

hyiso commented Feb 28, 2023

The output is:

Preparing lint_staged.
Running tasks for staged files.
Reverting to original state because of errors...
pub finished with exit code 1
husky
- pre-commit hook exited with code 1 (error)

The git status output is:

On branch xxxx
Your branch is behind 'origin/xxxx' by xx commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:
	modified:   .husky/pre-commit
	modified:   lib/app.dart
	modified:   lib/main.dart
	modified:   pubspec.lock
	modified:   pubspec.yaml

The .husky/pre-commit content is:

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

flutter pub run lint_staged

The configuration for lint_staged in pubspec.yaml is:

lint_staged:
  .dart: dart fix --apply
@hyiso
Copy link
Owner Author

hyiso commented Feb 28, 2023

flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.75.1)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

• No issues found!

flutter --version output:

Flutter 2.10.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7e9793dee1 (12 months ago) • 2022-03-02 11:23:12 -0600
Engine • revision bd539267b4
Tools • Dart 2.16.1 • DevTools 2.9.2

@hyiso
Copy link
Owner Author

hyiso commented Feb 28, 2023

According to the output, some errors is thrown during running dart fix --apply lib/app.dart and dart fix --apply lib/main.dart

@hyiso
Copy link
Owner Author

hyiso commented Feb 28, 2023

Running dart fix --apply lib/app.dart output:

Directory doesn't exist: lib/app.dart

Usage: dart fix [arguments]
-h, --help       Print this usage information.
-n, --dry-run    Preview the proposed changes but make no changes.
    --apply      Apply the proposed changes.

Run "dart help" to see global options.

Seems dart fix --apply on single file is not supported on Dart SDK version 2.16.1

@hyiso
Copy link
Owner Author

hyiso commented Feb 28, 2023

Related to dart-lang/sdk#43892

@hyiso
Copy link
Owner Author

hyiso commented Feb 28, 2023

Find that dart fix --apply for single file is supported since Dart SDK 2.18.0(Flutter SDK 3.3.0) dart-lang/sdk@467a1b0

@hyiso hyiso added bug Something isn't working compatibility labels Mar 3, 2023
@hyiso
Copy link
Owner Author

hyiso commented Mar 10, 2023

This can be fixed with 84aaa60

Now change lint_staged configuration in pubspec.yaml to

lint_staged:
  .dart: dart fix --apply <file>/../

lint_staged will lint the parent path for this file.

@hyiso hyiso closed this as completed Mar 10, 2023
@hyiso hyiso pinned this issue Mar 10, 2023
@hyiso hyiso changed the title pub finished with exit code 1 Running under Dart 2.18/Flutter 3.3 Apr 9, 2023
@hyiso hyiso unpinned this issue Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility
Projects
None yet
Development

No branches or pull requests

1 participant