Skip to content

Commit

Permalink
fix: added dateformatter & logger + updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Mar 6, 2024
1 parent f9e61f4 commit 0716081
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 11 deletions.
2 changes: 2 additions & 0 deletions lib/impaktfull_architecture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export 'src/model/data/error/localized_error.dart';
export 'src/model/data/error/network_error.dart';
export 'src/navigator/page_route/fade_in_page_route.dart';
export 'src/util/connectivity/connectivity.dart';
export 'src/util/date_formatter/date_formatter_util.dart';
export 'src/util/logger/logger.dart';
export 'src/util/storage/key_value/key_value_store.dart';
export 'src/util/storage/secure/secure_store.dart';
export 'src/util/storage/shared_prefs/shared_prefs_store.dart';
Expand Down
7 changes: 4 additions & 3 deletions lib/src/extension/list_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extension ListExtension<T> on List<T> {
Comparable<R>? Function(T item) by,
Comparable<V>? Function(T item) by2, {
bool ascending = true,
bool ascending2 = true,
}) {
sort((a, b) {
final byA = by(a);
Expand All @@ -30,9 +31,9 @@ extension ListExtension<T> on List<T> {
final byA2 = by2(a);
final byB2 = by2(b);
if (byA2 == null && byB2 == null) return 0;
if (byA2 == null) return ascending ? -1 : 1;
if (byB2 == null) return ascending ? 1 : -1;
return _compareValues(byA2, byB2, ascending);
if (byA2 == null) return ascending2 ? -1 : 1;
if (byB2 == null) return ascending2 ? 1 : -1;
return _compareValues(byA2, byB2, ascending2);
});
}
}
Expand Down
28 changes: 28 additions & 0 deletions lib/src/util/date_formatter/date_formatter_util.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:intl/intl.dart';

class DateFormatterUtil {
const DateFormatterUtil._();
static String formatDate(DateTime date) {
final localDate = date.toLocal();
final dateFormat = DateFormat('dd/MM/yyyy');
return dateFormat.format(localDate);
}

static String formatTime(DateTime date) {
final localDate = date.toLocal();
final dateFormat = DateFormat('HH:mm');
return dateFormat.format(localDate);
}

static String formatDateTime(DateTime date) {
final localDate = date.toLocal();
final dateFormat = DateFormat('dd/MM/yyyy HH:mm');
return dateFormat.format(localDate);
}

static String customFormat(DateTime date, String format) {
final localDate = date.toLocal();
final dateFormat = DateFormat(format);
return dateFormat.format(localDate);
}
}
30 changes: 30 additions & 0 deletions lib/src/util/logger/logger.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/foundation.dart';

class ImpaktfullLogger {
const ImpaktfullLogger._();

static void log(Object message) {
if (kDebugMode) print(message);
}

static void logError(String message, {Object? error, StackTrace? trace}) {
log(message);
if (error != null) {
log(error);
}
if (trace != null) {
log(trace);
}
}

static void logFullError(
String message, {
required Object? error,
required StackTrace? trace,
}) =>
logError(message, error: error, trace: trace);

static void verbose(Object message) => log(message);

static void debug(Object message) => log(message);
}
17 changes: 9 additions & 8 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,27 @@ environment:
flutter: ">=1.17.0"
dependencies:
connectivity_plus: ^5.0.2
device_info_plus: ^9.1.1
device_info_plus: ^9.1.2
flutter:
sdk: flutter
dio: ^5.4.0
dio: ^5.4.1
gap: ^3.0.1
get_it: ^7.6.4
impaktfull_ui: ^0.0.19
get_it: ^7.6.7
impaktfull_ui: ^0.0.31
injectable: ^2.3.2
intl: ^0.18.1
flutter_secure_storage: ^9.0.0
flutter_svg: ^2.0.9
flutter_svg: ^2.0.10+1
path: ^1.8.3
provider: ^6.1.1
provider: ^6.1.2
package_info_plus: ^5.0.1
path_provider: ^2.1.2
shared_preferences: ^2.2.2
snacky: ^0.0.5
snacky: ^0.0.14
sprintf: ^7.0.0
synchronized: ^3.1.0+1
tuple: ^2.0.2
url_launcher: ^6.2.2
url_launcher: ^6.2.5
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down

0 comments on commit 0716081

Please sign in to comment.