is possible have a configuration file in DART?
There are different way.
You could just create a map
my_config.dart
const Map properties = const {
'CHANNEL': 'sport',
'VIEW_ELEMENTS': const {
'LOADER_CLASS': '.loader',
'SPLASH_CLASS': '.splash'
}
}
then use it like
main.dart
import 'my_config.dart';
main() {
print(properties['VIEW_ELEMENTS']['SPLASH_CLASS']);
}
or you can use classes to get proper autocompletion and type checking
my_config.dart
const properties = const Properties('sport', const ViewElements('.loader', '.splash'));
class Properties {
final String channel;
final ViewElements viewElements;
const Properties(this.channel, this.viewElements;
}
class ViewElements {
final String loaderClass;
final String splashClass;
const ViewElements(this.loaderClass, this.splashClass);
}
main.dart
import 'my_config.dart';
main() {
print(properties.viewElements.splashClass);
}