Skip to content

Commit

Permalink
Merge pull request #28 from netglade/remove-isBlank-on-nullable-string
Browse files Browse the repository at this point in the history
Remove isBlank etc. on nullable String
  • Loading branch information
tenhobi authored Feb 16, 2024
2 parents e09a893 + cfa8de8 commit 345fa25
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.19.0",
"flavors": {}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ melos_my_project.iml
.vscode/*
!.vscode/tasks.json
!.vscode/settings.json
.fvm/flutter_sdk

.packages
.pub/
Expand Down
31 changes: 31 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"dart.flutterSdkPath": ".fvm/flutter_sdk",
"search.exclude": {
"**/.fvm": true,
"**/*.g.dart": true,
},
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
".idea/**": true,
".run/**": true,
},
// Remove from file watching
"files.watcherExclude": {
"**/.fvm": true
},
"dart.lineLength": 120,
"editor.rulers": [
120
],
"yaml.schemas": {
"https://json.schemastore.org/dart-build.json": [
"build.yaml"
]
},
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.dart": "${capture}.g.dart,${capture}.freezed.dart,${capture}.auto_mappr.dart"
},
"yaml.schemaStore.enable": false
}
3 changes: 3 additions & 0 deletions packages/netglade_utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.0.0
- Remove `isBlank`, `isNotBlank` from `String?` extension.

## 1.3.0
- Add `distinctBy` to iterable extensions.

Expand Down
2 changes: 1 addition & 1 deletion packages/netglade_utils/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ environment:
sdk: ^3.0.0

dependencies:
netglade_analysis: ^7.0.0
netglade_analysis: ^8.0.0
netglade_utils:
path: ..
15 changes: 0 additions & 15 deletions packages/netglade_utils/lib/src/extensions/string_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ extension StringExtensions on String {
}

extension NullableStringExtensions on String? {
/// Returns true when `this` is `String` which is `isBlank`.
/// When the value is `null`, returns `false`.
///
/// * String? is blank when it has a value and contains only whitespaces.
bool get isBlank {
return this?.isBlank ?? false;
}

/// Returns true when `this` is either `null` or `isBlank`.
///
/// * String? is blank when it has a value and contains only whitespaces.
Expand All @@ -55,13 +47,6 @@ extension NullableStringExtensions on String? {
return !isNullOrBlank;
}

/// Returns negation of [isBlank].
///
/// * String? is blank when it has a value and contains only whitespaces.
bool get isNotBlank {
return !isBlank;
}

/// Returns true when `this` is either `null` or `isBlank`.
bool get isNullOrEmpty {
return this?.isEmpty ?? true;
Expand Down
6 changes: 4 additions & 2 deletions packages/netglade_utils/lib/src/testing/mock_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import 'package:mocktail/mocktail.dart';
import 'package:netglade_utils/src/result/result.dart';

extension FutureVoidAnswer on When<Future<void>> {
void thenAnswerWithVoid() => thenAnswer((_) async => <void>{});
// ignore: no-empty-block, its ok
void thenAnswerWithVoid() => thenAnswer((_) async {});
}

extension VoidAnswer on When<void> {
void thenAnswerWithVoid() => thenAnswer((_) => <void>{});
// ignore: no-empty-block, its ok
void thenAnswerWithVoid() => thenAnswer((_) {});
}

extension GenericAnswer<T> on When<Future<T>> {
Expand Down
4 changes: 2 additions & 2 deletions packages/netglade_utils/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: netglade_utils
version: 1.3.0
version: 2.0.0
description: Dart utils used internally at netglade.
repository: https://github.com/netglade/flutter_core/tree/main/packages/netglade_utils
issue_tracker: https://github.com/netglade/flutter_core/issues
Expand All @@ -17,5 +17,5 @@ dependencies:
mocktail: ^1.0.0

dev_dependencies:
netglade_analysis: ^7.0.0
netglade_analysis: ^8.0.0
test: ^1.24.6
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ void main() {
group('on String?', () {
test('empty message is isBlank', () {
final String? value = '';
expect(value.isBlank, isTrue);
expect(value?.isBlank, isTrue);
});

test('null message is not isBlank', () {
final String? value = null;
expect(value.isBlank, isFalse);
expect(value?.isBlank, isNull);
});

test('message with whitespaces is isBlank', () {
final String? value = ' ';
expect(value.isBlank, isTrue);
expect(value?.isBlank, isTrue);
});

test('message with non-whitespace characters is not isBlank', () {
final String? value = 'xxx';
expect(value.isBlank, isFalse);
expect(value?.isBlank, isFalse);
});
});
});
Expand All @@ -84,22 +84,22 @@ void main() {
group('on String?', () {
test('empty message is not isNotBlank', () {
final String? value = '';
expect(value.isNotBlank, isFalse);
expect(value?.isNotBlank, isFalse);
});

test('message is null is isNotBlank', () {
test('message is null is null', () {
final String? value = null;
expect(value.isNotBlank, isTrue);
expect(value?.isNotBlank, isNull);
});

test('message has whitespaces is not isNotBlank', () {
final String? value = ' ';
expect(value.isNotBlank, isFalse);
expect(value?.isNotBlank, isFalse);
});

test('message has non-whitespace characters is isNotBlank', () {
final String? value = 'xxx';
expect(value.isNotBlank, isTrue);
expect(value?.isNotBlank, isTrue);
});
});
});
Expand Down

0 comments on commit 345fa25

Please sign in to comment.