mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
- Refactored and updated pages, router, DI modules, and feature implementations in both example projects: - client_app: main.dart and my_home_page.dart updated for improved navigation and structure. - postly: updated DI wiring, presentation pages, repository implementation, and routing logic. - Applied small improvements and code consistency changes in the examples. docs: add new documentation assets and benchmarking script BREAKING CHANGE: Examples now reflect the latest changes in the DI framework and are ready for Dart 3.8+ and cherrypick_generator element2 API compatibility.
33 lines
865 B
Dart
33 lines
865 B
Dart
import 'package:dartz/dartz.dart';
|
|
import '../domain/entity/post.dart';
|
|
import '../domain/repository/post_repository.dart';
|
|
import 'network/json_placeholder_api.dart';
|
|
|
|
class PostRepositoryImpl implements PostRepository {
|
|
final JsonPlaceholderApi api;
|
|
|
|
PostRepositoryImpl(this.api);
|
|
|
|
@override
|
|
Future<Either<Exception, List<Post>>> getPosts() async {
|
|
try {
|
|
final posts = await api.getPosts();
|
|
return Right(
|
|
posts.map((e) => Post(id: e.id, title: e.title, body: e.body)).toList(),
|
|
);
|
|
} catch (e) {
|
|
return Left(Exception(e.toString()));
|
|
}
|
|
}
|
|
|
|
@override
|
|
Future<Either<Exception, Post>> getPost(int id) async {
|
|
try {
|
|
final post = await api.getPost(id);
|
|
return Right(Post(id: post.id, title: post.title, body: post.body));
|
|
} catch (e) {
|
|
return Left(Exception(e.toString()));
|
|
}
|
|
}
|
|
}
|