flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.17k stars 26.65k forks source link

log is defined in math and developer packages and has a completely different purpose, we should avoid name collision in the standard library when it make sense #147474

Closed stephane-archer closed 2 weeks ago

stephane-archer commented 2 weeks ago

Use case

log is defined in math and developer packages and has a completely different purpose. not the best development experience. let's say you have:

import developer;

foo() {
int i = 0;
log(i)
}

then you need the math package for bar, you see the collision and do change your import too import developer as developer; import math then you add developer. when the compiler is complaining you add up with the following code

import developer as developer;

foo() {
int i = 0;
log(i) // BOOM!
}

bar() {
// my math function
}

Proposal

I think the standard library should avoid collision as much as possible. devLog could be an acceptable name the math library and the need to log thing is quite commun

danagbemava-nc commented 2 weeks ago

This should be reported on the dart-lang/sdk repository as the libraries reference are from the dart sdk.

On a side note, I believe this is the reason aliases can be assigned in to imports. This will happen several times with different libraries serving different purposes using the same names that might have different meanings. This isn't necessarily a bad thing.

Closing from here as this is not a flutter issue.

Thank you

stephane-archer commented 2 weeks ago

@danagbemava-nc I understand that alias is a way to solve the issue but remember to always alias the math library is not the best developer experience. I will open the issue on the dart-lang/SDK

stephane-archer commented 2 weeks ago

https://github.com/dart-lang/sdk/issues/55590

github-actions[bot] commented 1 day ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.