Skip to content

3.2 Architektur Freezed #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: architektur
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Check App:
- make format
- make clean
- make lint
artifacts:
untracked: true
paths:
- lib/

# Check code quality
code_quality:
Expand All @@ -48,6 +52,7 @@ Test:
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- flutter pub global activate junitreport
script:
- make clean
- flutter test --machine --coverage | tojunit -o report.xml
- lcov --summary coverage/lcov.info
- genhtml coverage/lcov.info --output=coverage
Expand All @@ -66,8 +71,6 @@ Build Android (.apk):
- main
script:
- make build-android-apk
dependencies:
- Check App
artifacts:
expire_in: 2 days
paths:
Expand Down
5 changes: 4 additions & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -171,10 +171,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -185,6 +187,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:counter_workshop/src/features/counter/domain/counter.model.dart'

/// Locale app database like SqlLite that providers a [CounterModel]
class CounterDatabase {
CounterModel _counter = CounterModel(value: 0);
CounterModel _counter = const CounterModel();

CounterModel getCounter() {
return _counter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class CounterResponseDto {
CounterResponseDto({
required this.sysId,
required this.counterValue,
this.createdAt,
this.updatedAt,
});
import 'package:freezed_annotation/freezed_annotation.dart';

final String sysId;
final int counterValue;
final DateTime? createdAt;
final DateTime? updatedAt;
part 'counter_response.dto.freezed.dart';

@freezed
class CounterResponseDto with _$CounterResponseDto {
const factory CounterResponseDto({
required String sysId,
required int counterValue,
DateTime? createdAt,
DateTime? updatedAt,
}) = _CounterResponseDto;
}
22 changes: 8 additions & 14 deletions lib/src/features/counter/domain/counter.model.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

// ignore: must_be_immutable
class CounterModel extends Equatable {
CounterModel({
this.value = 0,
this.id = '1',
});
part 'counter.model.freezed.dart';

/// technical counter id
final String id;

int value;

@override
List<Object?> get props => [id, value];
@freezed
class CounterModel with _$CounterModel {
const factory CounterModel({
@Default('1') String id,
@Default(0) int value,
}) = _CounterModel;
}
4 changes: 2 additions & 2 deletions lib/src/features/counter/presentation/counter.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class CounterController {
}

final CounterRepository counterRepository;
CounterModel counterModel = CounterModel();
CounterModel counterModel = const CounterModel();

Future<void> increment() async {
counterModel.value += 1;
counterModel = counterModel.copyWith(value: counterModel.value + 1);
counterRepository.updateCounter(counterModel: counterModel);
}
}
Loading