Does dart have some sort of alias for naming conflicts like this?
library flutterfly;
import 'dart:ui';
class Color {
Color._();
// Color should be the class from dart:ui instead of itself.
static Color white() {
return Color(#FFFFFFFF);
}
}
Import the library with a namespace/prefix:
import 'dart:ui' as ui;
class Color {
Color._();
static ui.Color white() {
return ui.Color(0xFFFFFFFF);
}
}
That said, because whoever imports your flutterfly library can choose whatever library prefix they want (if any), adding your own Color class to use as a namespace isn't very useful, and its presence likely would cause conflicts for anything that uses it. Effective Dart recommends against classes that contain only static members. For this example, you could use top-level functions instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With