File tree Expand file tree Collapse file tree 8 files changed +62
-4
lines changed Expand file tree Collapse file tree 8 files changed +62
-4
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ documentation: https://github.com/netglade/flutter_core/tree/main/packages/netgl
8
8
9
9
environment :
10
10
sdk : ^3.0.0
11
- flutter : ' >=3.0.0'
11
+ flutter : " >=3.0.0"
12
12
13
13
dependencies :
14
14
flutter :
@@ -19,7 +19,7 @@ dev_dependencies:
19
19
flutter_test :
20
20
sdk : flutter
21
21
mocktail : ^1.0.0
22
- netglade_analysis : ^8 .0.0
22
+ netglade_analysis : ^10 .0.0
23
23
test : ^1.24.6
24
24
25
25
flutter :
Original file line number Diff line number Diff line change
1
+
2
+ ## 2.1.0
3
+ - Add ` byNameOrDefault ` and ` byNameOrNull ` Enum's extensions.
4
+ - Add ` normalizeUrl ` and ` rtrim ` String's extensions.
5
+ - Add ` flattenedList ` on Iterable of Iterables extension.
6
+
1
7
## 2.0.0
2
8
- Remove ` isBlank ` , ` isNotBlank ` from ` String? ` extension.
3
9
Original file line number Diff line number Diff line change @@ -3,5 +3,9 @@ include: package:netglade_analysis/lints.yaml
3
3
dart_code_metrics :
4
4
extends :
5
5
- package:netglade_analysis/dcm.yaml
6
+ rules :
7
+ avoid-duplicate-collection-elements :
8
+ exclude :
9
+ - test/**
6
10
pubspec-rules :
7
11
prefer-publish-to-none : false
Original file line number Diff line number Diff line change
1
+ extension EnumExtensions <T extends Enum > on Iterable <T > {
2
+ /// Finds the enum value in this list with name [name] .
3
+ ///
4
+ /// Goes through this collection looking for an enum with
5
+ /// name [name] , as reported by [EnumName.name] .
6
+ /// Returns the first value with the given name. Such a value must be found.
7
+ T byNameOrDefault (String name, {required T defaultValue}) {
8
+ try {
9
+ return byName (name);
10
+ // ignore: avoid_catching_errors, byName throws it
11
+ } on ArgumentError catch (_) {
12
+ return defaultValue;
13
+ }
14
+ }
15
+
16
+ T ? byNameOrNull (String name) {
17
+ try {
18
+ return byName (name);
19
+ // ignore: avoid_catching_errors, byName throws it
20
+ } on ArgumentError catch (_) {
21
+ return null ;
22
+ }
23
+ }
24
+ }
Original file line number Diff line number Diff line change 1
1
export 'date_time_extensions.dart' ;
2
+ export 'enum_extensions.dart' ;
2
3
export 'future_extensions.dart' ;
3
4
export 'iterable_extensions.dart' ;
4
5
export 'object_extensions.dart' ;
Original file line number Diff line number Diff line change @@ -14,3 +14,7 @@ extension IterableExtensions<T> on Iterable<T> {
14
14
return result.values;
15
15
}
16
16
}
17
+
18
+ extension IterableIterableExtension <T > on Iterable <Iterable <T >> {
19
+ List <T > get flattenedList => [for (final elements in this ) ...elements];
20
+ }
Original file line number Diff line number Diff line change @@ -32,6 +32,25 @@ extension StringExtensions on String {
32
32
String ? ifBlank ([String ? defaultValue]) {
33
33
return isBlank ? defaultValue : this ;
34
34
}
35
+
36
+ /// Normalize supposedly string containing URL
37
+ ///
38
+ /// Appends https:// when does not start with.
39
+ /// Trims any trailing '/' chars.
40
+ String normalizeUrl () {
41
+ final value = trim ();
42
+
43
+ if (value.startsWith (RegExp (r'http[s]?:\/\/' ))) return value.rtrim ('/' );
44
+
45
+ return 'https://$value ' .rtrim ('/' );
46
+ }
47
+
48
+ /// Removes any trailing char from [chars] .
49
+ String rtrim (String chars) {
50
+ final pattern = RegExp ('[$chars ]+\$ ' );
51
+
52
+ return replaceAll (pattern, '' );
53
+ }
35
54
}
36
55
37
56
extension NullableStringExtensions on String ? {
Original file line number Diff line number Diff line change 1
1
name : netglade_utils
2
- version : 2.0 .0
2
+ version : 2.1 .0
3
3
description : Dart utils used internally at netglade.
4
4
repository : https://github.com/netglade/flutter_core/tree/main/packages/netglade_utils
5
5
issue_tracker : https://github.com/netglade/flutter_core/issues
@@ -17,5 +17,5 @@ dependencies:
17
17
mocktail : ^1.0.0
18
18
19
19
dev_dependencies :
20
- netglade_analysis : ^8 .0.0
20
+ netglade_analysis : ^10 .0.0
21
21
test : ^1.24.6
You can’t perform that action at this time.
0 commit comments