dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.04k stars 228 forks source link

Warn about missing Flutter SDK constraint and missing upper bound on flutter SDK constraint #2659

Open jonasfj opened 4 years ago

sigurdm commented 1 year ago

I don't think we want to do the upper bound - flutter no longer interprets the upper bound.

sigurdm commented 1 year ago

Could this be implemented in the analyzer or as a hint somehow? (@pq)

That would give the warning earlier.

Question is, how to detect that we rely on the flutter sdk?

pq commented 1 year ago

This could certainly and probably ideally would be done in the analyzer.

As for detecting flutter-ness, I wonder... I can think of some heuristics but I bet there's some prior art here. Maybe @goderbauer knows?

sigurdm commented 1 year ago

Yeah - in pub we could say that if any package in the resolution comes from the flutter sdk it is a flutter package - but I'm not sure that information is available to the analyzer.

Maybe it can be detected that dart:ui is in the import path somewhere...

pq commented 1 year ago

in pub we could say that if any package in the resolution comes from the flutter sdk

I'm not sure I understand this but it feels promising... Is this information in the package_config.json?

Popping up, I realize I'm not exactly sure what we want to check here. 😀

Are we looking for a missing bit like this in a pubspec?

dependencies:
  flutter:
    sdk: flutter
sigurdm commented 1 year ago

Popping up, I realize I'm not exactly sure what we want to check here. 😀

:) I guess we should paint the details a bit better:

To indicate that a package works with a given flutter release a flutter package should have a flutter sdk constraint like:

environment:
  flutter: '>3.1.0'

That is the missing bit.

However a package can leave out that constraint, and still depend on flutter:

Ideally we would like the diagnostic to cover all these cases, and suggest adding an sdk constraint on Flutter.

pq commented 1 year ago

Ah! This is very useful. Thanks for the clarification!

Ideally we would like the diagnostic to cover all these cases, and suggest adding an sdk constraint on Flutter.

I agree.