generated from saurav-maharana/flutter_template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
search_page.dart
50 lines (45 loc) · 1.84 KB
/
search_page.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:flutter/material.dart';
import 'package:flutter_template/presentation/base/exceptions/unhandled_effect_exception.dart';
import 'package:flutter_template/presentation/base/page/base_page.dart';
import 'package:flutter_template/presentation/base/widgets/snackbar/snackbar.dart';
import 'package:flutter_template/presentation/destinations/weather/search/search_screen_intent.dart';
import 'package:flutter_template/presentation/destinations/weather/search/search_screen_state.dart';
import 'package:flutter_template/presentation/destinations/weather/search/search_view_model.dart';
import 'package:flutter_template/presentation/destinations/weather/search/widgets/search_page_body/search_page_body.dart';
import 'package:flutter_template/presentation/entity/effect/effect.dart';
import 'package:flutter_template/presentation/entity/screen/screen.dart';
class SearchPage extends StatelessWidget {
final SearchScreen searchScreen;
SearchPage({
Key? key,
required this.searchScreen,
}) : super(key: key) {
// CatRemoteServiceImpl().searchCat(searchTerm: 'Sib').then(
// (value) => print(
// value.toString(),
// ),
// );
// GetIt.I.get<SearchCatUseCase>().call(param: 'Sib');
}
@override
Widget build(BuildContext context) {
return BasePage<SearchScreen, SearchScreenState, SearchViewModel>(
hideDefaultLoading: true,
viewModelProvider: searchViewModelProvider,
screen: searchScreen,
onAppBarBackPressed: (viewModel) => viewModel.onIntent(
SearchScreenIntent.back(),
),
body: const SearchPageBody(),
onEffect: _handleEffect,
);
}
_handleEffect(Effect effect) {
effect.maybeMap(
snackBar: (snackbarEffect) {
showSnackbar(snackbarEffect);
},
orElse: () => throw UnhandledEffectException(effect),
);
}
}