Skip to content

Commit 642cf37

Browse files
author
Veli Bacik
committed
package update has done
1 parent 7658b62 commit 642cf37

File tree

18 files changed

+280
-180
lines changed

18 files changed

+280
-180
lines changed

lib/core/base/model/base_view_model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import '../../init/network/vexana_manager.dart';
99
abstract class BaseViewModel {
1010
BuildContext context;
1111

12-
ICoreDio coreDio = NetworkManager.instance.coreDio;
12+
ICoreDioNullSafety coreDio = NetworkManager.instance.coreDio;
1313
VexanaManager vexanaManager = VexanaManager.instance;
1414
LocaleManager localeManager = LocaleManager.instance;
1515
NavigationService navigation = NavigationService.instance;

lib/core/components/button/normal_button.dart

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ class NormalButton extends StatelessWidget {
88
const NormalButton({Key key, this.child, this.onPressed}) : super(key: key);
99
@override
1010
Widget build(BuildContext context) {
11-
return RaisedButton(
12-
padding: EdgeInsets.all(15),
13-
elevation: 10,
11+
return ElevatedButton(
12+
style: ButtonStyle(
13+
padding: MaterialStateProperty.all(EdgeInsets.all(15)),
14+
elevation: MaterialStateProperty.all(10),
15+
),
1416
onPressed: onPressed,
1517
child: child,
1618
);
1719
}
1820
}
21+
22+
// BEFORE: NULL SAFETY
23+
// return RaisedButton(
24+
// padding: EdgeInsets.all(15),
25+
// elevation: 10,
26+
// onPressed: onPressed,
27+
// child: child,
28+
// );
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class NavigationConstants {
2-
static const TEST_VIEW = "/test";
2+
static const TEST_VIEW = '/test';
33
}

lib/core/init/lang/language_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
33
class LanguageManager {
44
static LanguageManager _instance;
55
static LanguageManager get instance {
6-
if (_instance == null) _instance = LanguageManager._init();
6+
_instance ??= LanguageManager._init();
77
return _instance;
88
}
99

lib/core/init/network/ICoreDio.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ abstract class ICoreDio {
1212
Map<String, Object> queryParameters,
1313
void Function(int, int) onReceiveProgress});
1414
}
15+
// MARK: Null SAfety
16+
17+
abstract class ICoreDioNullSafety {
18+
Future<IResponseModel<R>> send<R, T extends BaseModel>(String path,
19+
{@required HttpTypes type,
20+
@required T parseModel,
21+
dynamic data,
22+
Map<String, Object> queryParameters,
23+
void Function(int, int) onReceiveProgress});
24+
}
1525

1626
abstract class ICoreDioFull extends ICoreDio {
1727
Future<IResponseModel<R>> fetchNoNetwork<R, T extends BaseModel>(String path,
@@ -21,3 +31,13 @@ abstract class ICoreDioFull extends ICoreDio {
2131
Map<String, Object> queryParameters,
2232
void Function(int, int) onReceiveProgress});
2333
}
34+
35+
// MARK: Nul SAfety
36+
abstract class ICoreDioFullNulSafetyFull extends ICoreDioNullSafety {
37+
Future<IResponseModel<R>> fetchNoNetwork<R, T extends BaseModel>(String path,
38+
{@required HttpTypes type,
39+
@required T parseModel,
40+
dynamic data,
41+
Map<String, Object> queryParameters,
42+
void Function(int, int) onReceiveProgress});
43+
}

lib/core/init/network/core_dio.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'IResponseModel.dart';
1313

1414
part './network_core/core_operations.dart';
1515

16-
class CoreDio with DioMixin implements Dio, ICoreDio {
16+
class CoreDio with DioMixin implements Dio, ICoreDioNullSafety {
1717
@override
1818
final BaseOptions options;
1919

@@ -24,7 +24,7 @@ class CoreDio with DioMixin implements Dio, ICoreDio {
2424
}
2525

2626
@override
27-
Future<IResponseModel<R>> fetch<R, T extends BaseModel>(String path,
27+
Future<IResponseModel<R>> send<R, T extends BaseModel>(String path,
2828
{@required HttpTypes type,
2929
@required T parseModel,
3030
dynamic data,

lib/core/init/network/network_manager.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import 'core_dio.dart';
88
class NetworkManager {
99
static NetworkManager _instance;
1010
static NetworkManager get instance {
11-
if (_instance == null) _instance = NetworkManager._init();
11+
_instance ??= NetworkManager._init();
1212
return _instance;
1313
}
1414

15-
ICoreDio coreDio;
15+
ICoreDioNullSafety coreDio;
1616

1717
NetworkManager._init() {
1818
final baseOptions =
19-
BaseOptions(baseUrl: "https://jsonplaceholder.typicode.com/", headers: {"val": LocaleManager.instance.getStringValue(PreferencesKeys.TOKEN)});
19+
BaseOptions(baseUrl: 'https://jsonplaceholder.typicode.com/', headers: {"val": LocaleManager.instance.getStringValue(PreferencesKeys.TOKEN)});
2020
// _dio = Dio(baseOptions);
2121

2222
coreDio = CoreDio(baseOptions);

lib/view/authenticate/login/service/login_service.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class LoginService extends ILoginService {
1010

1111
@override
1212
Future<LoginResponseModel> fetchUserControl(LoginModel model) async {
13-
final response = await manager.fetch<LoginResponseModel, LoginResponseModel>(NetworkRoutes.LOGIN.rawValue,
13+
final response = await manager.send<LoginResponseModel, LoginResponseModel>(NetworkRoutes.LOGIN.rawValue,
1414
parseModel: LoginResponseModel(), method: RequestType.POST, data: model);
1515

1616
if (response.data is LoginResponseModel) {
@@ -20,3 +20,16 @@ class LoginService extends ILoginService {
2020
}
2121
}
2222
}
23+
24+
// BEFORE: null safety before
25+
// @override
26+
// Future<LoginResponseModel> fetchUserControl(LoginModel model) async {
27+
// final response = await manager.fetch<LoginResponseModel, LoginResponseModel>(NetworkRoutes.LOGIN.rawValue,
28+
// parseModel: LoginResponseModel(), method: RequestType.POST, data: model);
29+
30+
// if (response.data is LoginResponseModel) {
31+
// return response.data;
32+
// } else {
33+
// return null;
34+
// }
35+
// }

lib/view/authenticate/test/viewmodel/test_view_model.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ part 'test_view_model.g.dart';
1313
class TestViewModel = _TestViewModelBase with _$TestViewModel;
1414

1515
abstract class _TestViewModelBase with Store, BaseViewModel {
16+
@override
1617
void setContext(BuildContext context) {
1718
this.context = context;
1819
}
1920

21+
@override
2022
void init() {}
2123

2224
@observable
@@ -41,9 +43,12 @@ abstract class _TestViewModelBase with Store, BaseViewModel {
4143
Future<void> getSampleRequest() async {
4244
isLoading = true;
4345

44-
final response = await coreDio.fetch<List<TestModel>, TestModel>("x", type: HttpTypes.GET, parseModel: TestModel());
46+
final response = await coreDio.send<List<TestModel>, TestModel>('x', type: HttpTypes.GET, parseModel: TestModel());
4547
if (response.data is List<TestModel>) {
4648
} else {}
4749
isLoading = false;
4850
}
4951
}
52+
53+
// BEFORE: null safety
54+
// final response = await coreDio.fetch<List<TestModel>, TestModel>("x", type: HttpTypes.GET, parseModel: TestModel());

lib/view/home/build/feed/service/build_feed_service.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ class BuildFeedService extends IBuildFeedService with ServiceHelper {
1313
@override
1414
Future<List<HouseModel>> fetchUserHouseList() async {
1515
final response =
16-
await manager.fetch<HouseModel, List<HouseModel>>(NetworkRoutes.BUILD_HOME.rawValue, parseModel: HouseModel(), method: RequestType.GET);
16+
await manager.send<HouseModel, List<HouseModel>>(NetworkRoutes.BUILD_HOME.rawValue, parseModel: HouseModel(), method: RequestType.GET);
1717
showMessage(scaffoldyKey, response.error);
1818
return response.data;
1919
}
2020
}
21+
22+
// BEFORE: null safety
23+
// @override
24+
// Future<List<HouseModel>> fetchUserHouseList() async {
25+
// final response =
26+
// await manager.fetch<HouseModel, List<HouseModel>>(NetworkRoutes.BUILD_HOME.rawValue, parseModel: HouseModel(), method: RequestType.GET);
27+
// showMessage(scaffoldyKey, response.error);
28+
// return response.data;
29+
// }

0 commit comments

Comments
 (0)