Skip to content

Commit a0a0e86

Browse files
committed
Updated example
1 parent 70339e0 commit a0a0e86

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

example/lib/src/app/pages/home/home_controller.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ class HomeController extends Controller {
1010
int get counter => _counter;
1111
User get user => _user; // data used by the View
1212
final HomePresenter homePresenter;
13+
// Presenter should always be initialized this way
1314
HomeController(usersRepo): _counter = 0, homePresenter = HomePresenter(usersRepo), super();
1415

1516
@override
17+
// this is called automatically by the parent class
1618
void initListeners() {
1719
homePresenter.getUserOnNext = (User user) {
1820
print(user.toString());
@@ -42,7 +44,7 @@ class HomeController extends Controller {
4244

4345
@override
4446
void dispose() {
45-
homePresenter.dispose();
47+
homePresenter.dispose(); // don't forget to dispose of the presenter
4648
super.dispose();
4749
}
4850

example/lib/src/app/pages/home/home_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _HomePageState extends ViewState<HomePage, HomeController> {
2525
title: Text(widget.title),
2626
),
2727
body: Scaffold(
28-
key: globalKey,
28+
key: globalKey, // built in global key for the ViewState for easy access in the controller
2929
body: Center(
3030
child: Column(
3131
mainAxisAlignment: MainAxisAlignment.center,

example/lib/src/domain/usecases/get_user_usecase.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class GetUserUseCase extends UseCase<GetUserUseCaseResponse, GetUserUseCaseParam
3030
}
3131
}
3232

33+
/// Wrapping params inside an object makes it easier to change later
3334
class GetUserUseCaseParams {
3435
final String uid;
3536
GetUserUseCaseParams(this.uid);
3637
}
3738

39+
/// Wrapping response inside an object makes it easier to change later
3840
class GetUserUseCaseResponse {
3941
final User user;
4042
GetUserUseCaseResponse(this.user);

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ packages:
4747
name: flutter_clean_architecture
4848
url: "https://pub.dartlang.org"
4949
source: hosted
50-
version: "0.0.1"
50+
version: "1.0.1"
5151
flutter_test:
5252
dependency: "direct dev"
5353
description: flutter

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies:
2323
# The following adds the Cupertino Icons font to your application.
2424
# Use with the CupertinoIcons class for iOS style icons.
2525
cupertino_icons: ^0.1.2
26-
flutter_clean_architecture: ^0.0.1
26+
flutter_clean_architecture: ^1.0.2
2727
rxdart: ^0.20.0
2828
dev_dependencies:
2929
flutter_test:

0 commit comments

Comments
 (0)