v1.0.19 dotenv logging test
This commit is contained in:
parent
7a27a89397
commit
dbb3b5005d
@ -1,5 +1,8 @@
|
||||
Workout Test and Diet 4 You Common Util Functions
|
||||
|
||||
Version 1.0.19
|
||||
dotenv logging test
|
||||
|
||||
Version 1.0.18
|
||||
debug by dotenv
|
||||
|
||||
|
2
assets/.env
Normal file
2
assets/.env
Normal file
@ -0,0 +1,2 @@
|
||||
dotenv=1
|
||||
debug=2
|
@ -1,5 +1,3 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
@ -8,11 +6,11 @@ import 'package:intl/intl.dart';
|
||||
mixin Logging {
|
||||
void log(String message) {
|
||||
String debug = dotenv.get("debug", fallback: "0");
|
||||
String? platformDebug = Platform.environment['debug'];
|
||||
|
||||
if (debug == "2") {
|
||||
print("Debug-mode: $kDebugMode, dotenv: $debug, platform: $platformDebug");
|
||||
print("Debug-mode: $kDebugMode, dotenv: $debug");
|
||||
}
|
||||
if (kDebugMode || debug == "1" || platformDebug == "1") {
|
||||
if (kDebugMode || debug == "1" || debug == "2") {
|
||||
DateTime time = DateTime.now();
|
||||
print(DateFormat('yyyy-MM-dd HH:mm:ss ').format(time) + message);
|
||||
}
|
||||
|
39
pubspec.yaml
39
pubspec.yaml
@ -1,6 +1,6 @@
|
||||
name: workouttest_util
|
||||
description: Workout Test app and web functions.
|
||||
version: 1.0.18
|
||||
version: 1.0.19
|
||||
|
||||
environment:
|
||||
sdk: ">=2.18.6 <3.0.0"
|
||||
@ -44,39 +44,6 @@ dev_dependencies:
|
||||
sdk: flutter
|
||||
flutter_lints: ^2.0.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
# To add assets to your package, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
#
|
||||
# For details regarding assets in packages, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||
|
||||
# To add custom fonts to your package, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts in packages, see
|
||||
# https://flutter.dev/custom-fonts/#from-packages
|
||||
assets:
|
||||
- assets/.env
|
||||
|
21
test/logging_test.dart
Normal file
21
test/logging_test.dart
Normal file
@ -0,0 +1,21 @@
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:workouttest_util/util/logging.dart';
|
||||
|
||||
class LoggingTest with Logging {}
|
||||
|
||||
main() {
|
||||
late LoggingTest mockLogging;
|
||||
setUp(() async {
|
||||
mockLogging = LoggingTest();
|
||||
await dotenv.load(fileName: "assets/.env");
|
||||
});
|
||||
|
||||
group('logging', () {
|
||||
test('test dotenv', () {
|
||||
String debug = dotenv.get("debug", fallback: "1");
|
||||
mockLogging.log("message");
|
||||
expect(debug, "2");
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user