小编Viv*_*vek的帖子

Flutter Clean 架构 - 与领域实体和数据模型的冲突

我是flutter的初学者,学习flutter已经有6个月左右的时间了。我目前正在开发费用管理应用程序。我发现干净的架构模式非常有趣,尽管它需要比其他方式更多(!)的编码。我可以真实地说出这一点,因为我几乎制作了一个功能性应用程序,现在尝试从头开始使用干净的架构。我并不完全遵循https://pub.dev/packages/flutter_clean_architecture中的指南,而是尝试遵循干净的概念 - 域 -> 数据 -> UI

这是我到目前为止所做的:

领域

  1. 在域内创建实体。让我尝试将问题与其中一个实体(用户事务)隔离开来
abstract class UserTransactionEntity {
  final int? transactionID;
  final String merchant;
  final amount;
  final String category;
  final String paymentType;
  final String paymentAccount;
  final String transactionDate;
  final String? transactionNotes;
  final String transactionType;

  ///User Transaction Entity Class

  UserTransactionEntity(
      {required this.transactionType,
      required this.merchant,
      this.amount,
      required this.category,
      required this.paymentType,
      required this.paymentAccount,
      required this.transactionDate,
      this.transactionNotes,
      this.transactionID});
}

Run Code Online (Sandbox Code Playgroud)
  1. 创建了域存储库(界面?)
///UserTransaction Interface
abstract class UserTransactionRepository {
  Future<List<UserTransactionEntity>> getTransactionList();
  postTransaction(UserTransactionEntity transaction);
}

Run Code Online (Sandbox Code Playgroud)
  1. 在域中创建单独的用例

基本用例

abstract class UseCase<Type, …
Run Code Online (Sandbox Code Playgroud)

architecture flutter clean-architecture

3
推荐指数
1
解决办法
6698
查看次数

标签 统计

architecture ×1

clean-architecture ×1

flutter ×1