https://github.com/medeity/lib_mvp
An mvp pattern implementation of flutter
https://github.com/medeity/lib_mvp
Last synced: 8 months ago
JSON representation
An mvp pattern implementation of flutter
- Host: GitHub
- URL: https://github.com/medeity/lib_mvp
- Owner: MeDeity
- License: other
- Created: 2019-08-23T07:40:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-13T08:57:54.000Z (over 6 years ago)
- Last Synced: 2025-10-22T22:55:59.707Z (8 months ago)
- Language: Dart
- Size: 54.7 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lib_mvp
an achieve of mvp framework,
## Thanks
Thanks to the [simplezhli -> flutter deer](https://github.com/simplezhli/flutter_deer) project,
this library is an MVP implementation separated from this project.
This is a strongly coupled tool library with the following open source libraries built in:
1. [dio](https://github.com/flutterchina/dio): ^2.1.13
2. [sprintf](https://github.com/Naddiseo/dart-sprintf): ^4.0.0
3. [rxdart](https://github.com/ReactiveX/rxdart): ^0.21.0
4. [oktoast](https://github.com/OpenFlutter/flutter_oktoast): ^2.1.8
## Getting Started
#### Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
```
dependencies:
lib_mvp: ^1.0.0
```
2.Install it
You can install packages from the command line:
with Flutter:
```
$ flutter pub get
```
Now in your Dart code, you can use:
```
import 'package:lib_mvp/lib_mvp.dart';
```
#### 一、 init OKToast:
```
@override
Widget build(BuildContext context) {
return OKToast(//init OKToast
child: MaterialApp(
title: 'MVP Framework Test',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: IndexPage(),
),
);
}
```
#### 二、xxxPageState extends BasePageState ,Take IndexPage as an example
```
class IndexPage extends StatefulWidget {
@override
State createState() {
return IndexPageState();
}
}
class IndexPageState extends BasePageState {
@override
IndexPagePresenter createPresenter() {
return IndexPagePresenter();
}
}
```
#### 三、Create xxxPagePresenter,Take IndexPagePresenter as an example
```
class IndexPagePresenter extends BasePagePresenter{
void requestUserInfo(){
requestNetwork(Method.get,
url: Api.users,
baseUrl: Api.baseUrl,
onSuccess: (response){
Map _map = json.decode(response?.data.toString());
String result = json.encode(_map);
ResponseUserInfoEntity entity = EntityFactory.generateOBJ(_map["data"]);
view.updateResponseView(entity);
},
);
}
}
```
Hope you enjoy it!!!!
Here is a [sample demo](https://github.com/MeDeity/flutter_mvp) show how to use this mvp framework,scan this qrcode to download android demo.

Or It is especially recommended that you check out this open source project =>[simplezhli -> flutter deer](https://github.com/simplezhli/flutter_deer)