我是flutter的初学者,学习flutter已经有6个月左右的时间了。我目前正在开发费用管理应用程序。我发现干净的架构模式非常有趣,尽管它需要比其他方式更多(!)的编码。我可以真实地说出这一点,因为我几乎制作了一个功能性应用程序,现在尝试从头开始使用干净的架构。我并不完全遵循https://pub.dev/packages/flutter_clean_architecture中的指南,而是尝试遵循干净的概念 - 域 -> 数据 -> UI
这是我到目前为止所做的:
领域
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)
///UserTransaction Interface
abstract class UserTransactionRepository {
Future<List<UserTransactionEntity>> getTransactionList();
postTransaction(UserTransactionEntity transaction);
}
Run Code Online (Sandbox Code Playgroud)
基本用例
abstract class UseCase<Type, …Run Code Online (Sandbox Code Playgroud)