Skip to content

Commit caf8a6a

Browse files
committed
Upgrade simple_blocs to latest version
1 parent 573a63a commit caf8a6a

File tree

12 files changed

+318
-112
lines changed

12 files changed

+318
-112
lines changed

mobx/analysis_options.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
# packages, and plugins designed to encourage good coding practices.
1010
include: package:flutter_lints/flutter.yaml
1111

12+
analyzer:
13+
language:
14+
strict-casts: true
15+
strict-inference: true
16+
strict-raw-types: true
17+
1218
linter:
1319
# The lint rules applied to this project can be customized in the
1420
# section below to disable rules from the `package:flutter_lints/flutter.yaml`

mobx/lib/details_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DetailsScreen extends StatelessWidget {
3131
onPressed: () {
3232
Navigator.push(
3333
context,
34-
MaterialPageRoute(
34+
MaterialPageRoute<void>(
3535
builder: (context) => EditTodoScreen(
3636
todo: todo,
3737
onEdit: () => Navigator.pop(context),

simple_blocs/.gitignore

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# Files and directories created by pub
2-
.packages
3-
.pub/
4-
build/
5-
# Remove the following pattern if you wish to check in your lock file
6-
pubspec.lock
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/
74

8-
# Directory created by dartdoc
9-
doc/api/
5+
# Avoid committing pubspec.lock for library packages; see
6+
# https://dart.dev/guides/libraries/private-files#pubspeclock.
7+
pubspec.lock

simple_blocs/CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Changelog
1+
## 1.0.0
22

3-
## 0.0.1
4-
5-
- Initial version, created by Stagehand
3+
- Initial version.

simple_blocs/README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
1-
# blocs
1+
<!--
2+
This README describes the package. If you publish this package to pub.dev,
3+
this README's contents appear on the landing page for your package.
24
3-
A library for Dart developers.
5+
For information about how to write a good package README, see the guide for
6+
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
47
5-
Created from templates made available by Stagehand under a BSD-style
6-
[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).
8+
For general information about developing packages, see the Dart guide for
9+
[creating packages](https://dart.dev/guides/libraries/create-packages)
10+
and the Flutter guide for
11+
[developing packages and plugins](https://flutter.dev/to/develop-packages).
12+
-->
713

8-
## Usage
14+
TODO: Put a short description of the package here that helps potential users
15+
know whether this package might be useful for them.
16+
17+
## Features
18+
19+
TODO: List what your package can do. Maybe include images, gifs, or videos.
920

10-
A simple usage example:
21+
## Getting started
1122

12-
import 'package:simple_blocs/blocs.dart';
23+
TODO: List prerequisites and provide or point to information on how to
24+
start using the package.
25+
26+
## Usage
1327

14-
main() {
15-
var awesome = new Awesome();
16-
}
28+
TODO: Include short and useful examples for package users. Add longer examples
29+
to `/example` folder.
1730

18-
## Features and bugs
31+
```dart
32+
const like = 'sample';
33+
```
1934

20-
Please file feature requests and bugs at the [issue tracker][tracker].
35+
## Additional information
2136

22-
[tracker]: http://example.com/issues/replaceme
37+
TODO: Tell users more about the package: where to find more information, how to
38+
contribute to the package, how to file issues, what response they can expect
39+
from the package authors, and more.

simple_blocs/analysis_options.yaml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
118
analyzer:
2-
# exclude:
3-
# - path/to/excluded/files/**
4-
5-
# Lint rules and documentation, see http://dart-lang.github.io/linter/lints
6-
linter:
7-
rules:
8-
- cancel_subscriptions
9-
- hash_and_equals
10-
- iterable_contains_unrelated_type
11-
- list_remove_unrelated_type
12-
- test_types_in_equals
13-
- unrelated_type_equality_checks
14-
- valid_regexps
19+
language:
20+
strict-casts: true
21+
strict-inference: true
22+
strict-raw-types: true
23+
24+
# linter:
25+
# rules:
26+
# - camel_case_types
27+
28+
# For more information about the core and recommended set of lints, see
29+
# https://dart.dev/go/core-lints
30+
31+
# For additional information about configuring this file, see
32+
# https://dart.dev/guides/language/analysis-options

simple_blocs/lib/src/models/todo.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ class Todo {
99
final String note;
1010
final String task;
1111

12-
Todo(this.task, {this.complete = false, String note = '', String id})
13-
: this.note = note ?? '',
14-
this.id = id ?? Uuid().generateV4();
12+
Todo(this.task, {this.complete = false, this.note = '', String? id})
13+
: id = id ?? Uuid().generateV4();
1514

16-
Todo copyWith({bool complete, String id, String note, String task}) {
15+
Todo copyWith({bool? complete, String? id, String? note, String? task}) {
1716
return Todo(
1817
task ?? this.task,
1918
complete: complete ?? this.complete,
@@ -48,9 +47,9 @@ class Todo {
4847
static Todo fromEntity(TodoEntity entity) {
4948
return Todo(
5049
entity.task,
51-
complete: entity.complete ?? false,
50+
complete: entity.complete,
5251
note: entity.note,
53-
id: entity.id ?? Uuid().generateV4(),
52+
id: entity.id,
5453
);
5554
}
5655
}

simple_blocs/lib/src/todos_interactor.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'dart:async';
22

3+
import 'package:collection/collection.dart';
4+
import 'package:rxdart/rxdart.dart';
35
import 'package:simple_blocs/simple_blocs.dart';
46
import 'package:todos_repository_core/todos_repository_core.dart';
57

@@ -21,10 +23,8 @@ class TodosInteractor {
2123

2224
Stream<Todo> todo(String id) {
2325
return todos
24-
.map((todos) {
25-
return todos.firstWhere((todo) => todo.id == id, orElse: () => null);
26-
})
27-
.where((todo) => todo != null);
26+
.map<Todo?>((todos) => todos.firstWhereOrNull((todo) => todo.id == id))
27+
.whereNotNull();
2828
}
2929

3030
Stream<bool> get allComplete => todos.map(_allComplete);

simple_blocs/lib/src/todos_list_bloc.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class TodosListBloc {
5050
case VisibilityFilter.completed:
5151
return todo.complete;
5252
case VisibilityFilter.all:
53-
default:
5453
return true;
5554
}
5655
}).toList();

simple_blocs/pubspec.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
name: simple_blocs
22
description: The Business Logic Components for a Todo App - Simplfied
3+
version: 1.0.0
4+
publish_to: "none"
35

46
environment:
5-
sdk: '>=2.0.0-dev.28.0 <3.0.0'
7+
sdk: ^3.9.0
68

79
dependencies:
10+
collection: ^1.15.0
11+
rxdart: ^0.28.0
812
todos_repository_core:
913
path: ../todos_repository_core
10-
rxdart: ^0.23.1
1114

1215
dev_dependencies:
13-
test:
14-
mockito:
16+
lints: ^6.0.0
17+
test: ^1.25.6
18+
mockito: ^5.5.0

0 commit comments

Comments
 (0)