Compare commits
4 Commits
v1.0.3
...
1be7ecaa33
| Author | SHA1 | Date | |
|---|---|---|---|
| 1be7ecaa33 | |||
| 1d41d08666 | |||
|
|
361bdc2f49 | ||
| 05f41dac54 |
@@ -15,4 +15,11 @@
|
|||||||
- Add mutable configuration provider
|
- Add mutable configuration provider
|
||||||
- Split tests file
|
- Split tests file
|
||||||
- Fixed and nullable functions
|
- Fixed and nullable functions
|
||||||
- Able to set or remove config from system config
|
- Able to set or remove config from system config
|
||||||
|
|
||||||
|
## 1.0.4
|
||||||
|
- Fixed format classes and files
|
||||||
|
|
||||||
|
## 1.0.5
|
||||||
|
- Fixed simple provider for final configs variable
|
||||||
|
- Fixed setAll function that set itself, in simple provider
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
# Dart Configurable Environment
|
# Dart Configurable Environment
|
||||||
|
|
||||||
|
[](https://pub.dartlang.org/packages/configurable)
|
||||||
|
|
||||||
- [x] Allow to get property from env file
|
- [x] Allow to get property from env file
|
||||||
- [x] Cache property for runtime
|
- [x] Cache property for runtime
|
||||||
- [x] Dotenv file support (use DotenvConfigurationProvider)
|
- [x] Dotenv file support (use DotenvConfigurationProvider)
|
||||||
@@ -7,6 +9,9 @@
|
|||||||
- [x] Support nullsafety (dart 2.12.2+)
|
- [x] Support nullsafety (dart 2.12.2+)
|
||||||
- [x] Custom configuration provider
|
- [x] Custom configuration provider
|
||||||
|
|
||||||
|
# Issue
|
||||||
|
- Flutter app not support for dotenv (.env) when run on devices
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ abstract class MutableConfigurationProvider implements ConfigurationProvider {
|
|||||||
|
|
||||||
/// Allow to remove all values from config values
|
/// Allow to remove all values from config values
|
||||||
void removeAll();
|
void removeAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ import 'package:configurable/mutable_configurable_provider.dart';
|
|||||||
/// @author sombochea
|
/// @author sombochea
|
||||||
/// @since 1.0.0
|
/// @since 1.0.0
|
||||||
class SimpleConfigurationProvider implements MutableConfigurationProvider {
|
class SimpleConfigurationProvider implements MutableConfigurationProvider {
|
||||||
Map<String, String?> configs = {};
|
final Map<String, String?> _configs = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? getOrNull(String key, {String? defaultValue}) {
|
String? getOrNull(String key, {String? defaultValue}) {
|
||||||
var value = configs[key];
|
var value = _configs[key];
|
||||||
|
|
||||||
/// if value is null, then set the default value and return it back
|
/// if value is null, then set the default value and return it back
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
configs[key] = defaultValue;
|
_configs[key] = defaultValue;
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,26 +22,26 @@ class SimpleConfigurationProvider implements MutableConfigurationProvider {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool containsKey(String key) {
|
bool containsKey(String key) {
|
||||||
return configs.containsKey(key);
|
return _configs.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void set(String key, String? value) {
|
void set(String key, String? value) {
|
||||||
configs[key] = value;
|
_configs[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void remove(String key) {
|
void remove(String key) {
|
||||||
configs.remove(key);
|
_configs.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void removeAll() {
|
void removeAll() {
|
||||||
configs.clear();
|
_configs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void setAll(Map<String, String?> configs) {
|
void setAll(Map<String, String?> configs) {
|
||||||
configs.addAll(configs);
|
_configs.addAll(configs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: configurable
|
name: configurable
|
||||||
description: System Configuration and Dotenv Environment for Dart and Flutter
|
description: System Configuration and Dotenv Environment for Dart and Flutter
|
||||||
version: 1.0.3
|
version: 1.0.5
|
||||||
homepage: https://github.com/CUBETIQ/system-config-dart
|
homepage: https://github.com/CUBETIQ/system-config-dart
|
||||||
repository: https://github.com/CUBETIQ/system-config-dart.git
|
repository: https://github.com/CUBETIQ/system-config-dart.git
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:configurable/configurable.dart' show getConfigOrNull, hasConfigkey;
|
import 'package:configurable/configurable.dart'
|
||||||
|
show getConfigOrNull, hasConfigkey;
|
||||||
import 'package:configurable/simple_configuration_provider.dart';
|
import 'package:configurable/simple_configuration_provider.dart';
|
||||||
import 'package:configurable/system_config.dart';
|
import 'package:configurable/system_config.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
@@ -7,7 +8,7 @@ void main() {
|
|||||||
test('get system config by key', () {
|
test('get system config by key', () {
|
||||||
var key = 'app.name';
|
var key = 'app.name';
|
||||||
var value = 'CUBETIQ';
|
var value = 'CUBETIQ';
|
||||||
|
|
||||||
// set simple provider
|
// set simple provider
|
||||||
SystemConfig.setProvider(SimpleConfigurationProvider());
|
SystemConfig.setProvider(SimpleConfigurationProvider());
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import 'package:test/test.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
test('just call env', () {
|
test('just call env', () {
|
||||||
load();
|
load();
|
||||||
|
|
||||||
var result = env['app.title'];
|
var result = env['app.title'];
|
||||||
|
|
||||||
expect('CUBETIQ Solution', equals(result));
|
expect('CUBETIQ Solution', equals(result));
|
||||||
|
|||||||
Reference in New Issue
Block a user