Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
* remove deprecated methods, associated classes and files

* update CHANGELOG

* bump version to 1.0.0
  • Loading branch information
Nikoro authored Feb 5, 2024
1 parent 6c0b234 commit f1f184b
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 254 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 1.0.0

**BREAKING CHANGES**:
>
> Removed `initialize` method -> use `SDTFScope` instead
>
> Removed `dateFormat` getter -> use `getDatePattern()` instead
>
> Removed `mediumDateFormat` getter -> use `getMediumDatePattern()` instead
>
> Removed `longDateFormat` getter -> use `getLongDatePattern()` instead
>
> Removed `timeFormat` getter -> use `getTimePattern()` instead
## 0.7.2

Updated the SDK constraint to '>=2.18.6 <4.0.0'
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.7.2"
version: "1.0.0"
term_glyph:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example_with_tests/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.7.2"
version: "1.0.0"
term_glyph:
dependency: transitive
description:
Expand Down
11 changes: 0 additions & 11 deletions lib/src/errors/not_initialized_error.dart

This file was deleted.

10 changes: 0 additions & 10 deletions lib/src/fallbacks.dart

This file was deleted.

99 changes: 0 additions & 99 deletions lib/system_date_time_format.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:system_date_time_format/src/errors/not_initialized_error.dart';
import 'package:system_date_time_format/src/errors/sdtf_scope_not_found_error.dart';
import 'package:system_date_time_format/src/fallbacks.dart';
import 'package:system_date_time_format/src/patterns.dart';
import 'package:system_date_time_format/src/widgets/sdtf_scope_inherited.dart';

Expand Down Expand Up @@ -64,101 +62,4 @@ class SystemDateTimeFormat {

return sDTFScope.patterns;
}

/// Initializes the plugin.
/// Call this method before using the plugin further.
/// It will be removed in 1.0.0
@Deprecated("Use SDTFScope instead.")
Future<void> initialize({
String dateFormatFallback = Fallbacks.dateFormat,
String mediumDateFormatFallback = Fallbacks.mediumDateFormat,
String longDateFormatFallback = Fallbacks.longDateFormat,
String timeFormatFallback = Fallbacks.timeFormat,
}) async {
final platform = SystemDateTimeFormatPlatformInterface.instance;
_dateFormat = await _try(
platform.getDatePattern,
fallback: dateFormatFallback,
);
_mediumDateFormat = await _try(
platform.getMediumDatePattern,
fallback: mediumDateFormatFallback,
);
_longDateFormat = await _try(
platform.getLongDatePattern,
fallback: longDateFormatFallback,
);
_timeFormat = await _try(
platform.getTimePattern,
fallback: timeFormatFallback,
);
}

/// Returns a short version of date format.
/// Throws [NotInitializedError] when plugin was not initialized
/// It will be removed in 1.0.0
@Deprecated("Use getDatePattern() instead.")
String get dateFormat {
if (_dateFormat == null) {
throw NotInitializedError('dateFormat');
}
return _dateFormat!;
}

/// Returns a medium version of date format.
/// Throws [NotInitializedError] when plugin was not initialized
/// It will be removed in 1.0.0
@Deprecated("Use getMediumDatePattern() instead.")
String get mediumDateFormat {
if (_mediumDateFormat == null) {
throw NotInitializedError('mediumDateFormat');
}
return _mediumDateFormat!;
}

/// Returns a long version of date format.
/// Throws [NotInitializedError] when plugin was not initialized
/// It will be removed in 1.0.0
@Deprecated("Use getLongDatePattern() instead.")
String get longDateFormat {
if (_longDateFormat == null) {
throw NotInitializedError('longDateFormat');
}
return _longDateFormat!;
}

/// Returns time format.
/// Throws [NotInitializedError] when plugin was not initialized
/// It will be removed in 1.0.0
@Deprecated("Use getTimePattern() instead.")
String get timeFormat {
if (_timeFormat == null) {
throw NotInitializedError('timeFormat');
}
return _timeFormat!;
}

/// Helper function for catching [PlatformException] and returning a fallback when that happen
Future<String> _try(
Future<String?> Function() function, {
required String fallback,
}) async {
try {
return await function() ?? fallback;
} on PlatformException {
return fallback;
}
}

/// Holds (dateFormat) value after plugin initialization
String? _dateFormat;

/// Holds (mediumDateFormat) value after plugin initialization
String? _mediumDateFormat;

/// Holds (longDateFormat) value after plugin initialization
String? _longDateFormat;

/// Holds (timeFormat) value after plugin initialization
String? _timeFormat;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: system_date_time_format
description: A plugin for getting date and time format patterns from device system settings.
version: 0.7.2
version: 1.0.0
repository: https://github.com/Nikoro/system_date_time_format
issue_tracker: https://github.com/Nikoro/system_date_time_format/issues

Expand Down
14 changes: 0 additions & 14 deletions test/src/errors/not_ititialized_error_test.dart

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions test/system_date_time_format/system_date_time_format_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,5 @@ void main() {
final patterns = SystemDateTimeFormat.of(context);
expect(patterns, Stubs.allPatterns);
});

test('dateFormat returns correct pattern: [${Stubs.datePattern}]',
() async {
await SystemDateTimeFormat().initialize();
expect(SystemDateTimeFormat().dateFormat, Stubs.datePattern);
});

test(
'mediumDateFormat returns correct pattern: [${Stubs.mediumDatePattern}]',
() async {
await SystemDateTimeFormat().initialize();
expect(SystemDateTimeFormat().mediumDateFormat, Stubs.mediumDatePattern);
});

test('longDateFormat returns correct pattern: [${Stubs.longDatePattern}]',
() async {
await SystemDateTimeFormat().initialize();
expect(SystemDateTimeFormat().longDateFormat, Stubs.longDatePattern);
});

test('timeFormat returns correct pattern: [${Stubs.timePattern}]',
() async {
await SystemDateTimeFormat().initialize();
expect(SystemDateTimeFormat().timeFormat, Stubs.timePattern);
});
});
}

0 comments on commit f1f184b

Please sign in to comment.