Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gmalpha_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile
gmalpha_flutter
Commits
2c0efeea
Commit
2c0efeea
authored
Sep 05, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
29e28e7c
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
1043 additions
and
568 deletions
+1043
-568
GeneratedPluginRegistrant.java
...in/java/io/flutter/plugins/GeneratedPluginRegistrant.java
+0
-2
build.gradle
.android/app/build.gradle
+2
-2
local.properties
.android/local.properties
+0
-4
GeneratedPluginRegistrant.m
...utterPluginRegistrant/Classes/GeneratedPluginRegistrant.m
+0
-2
FlutterPluginRegistrant.podspec
...r/FlutterPluginRegistrant/FlutterPluginRegistrant.podspec
+0
-1
build.yaml
build.yaml
+15
-7
ApiBuilderGenerator.dart
lib/Annotations/Generator/ApiBuilderGenerator.dart
+0
-106
ServiceGenerator.dart
lib/Annotations/Generator/ServiceGenerator.dart
+105
-0
UserGenerator.dart
lib/Annotations/Generator/UserGenerator.dart
+20
-15
ServiceGenerator.dart
lib/Annotations/ServiceGenerator.dart
+8
-5
Get.dart
lib/Annotations/anno/Get.dart
+11
-0
Post.dart
lib/Annotations/anno/Post.dart
+11
-0
Query.dart
lib/Annotations/anno/Query.dart
+11
-0
ServiceCenter.dart
lib/Annotations/anno/ServiceCenter.dart
+10
-0
app_module.dart
lib/commonModel/app_module.dart
+3
-40
bloc_base.dart
lib/commonModel/bloc/bloc_base.dart
+3
-0
bloc_provider.dart
lib/commonModel/bloc/bloc_provider.dart
+57
-0
MmkvUtil.dart
lib/commonModel/mmkv/MmkvUtil.dart
+60
-0
DioUtil.dart
lib/commonModel/net/DioUtil.dart
+150
-39
main.dart
lib/main.dart
+4
-1
UserRouter.dart
lib/userModel/UserRouter.dart
+0
-3
UserRouterImpl.dart
lib/userModel/UserRouterImpl.dart
+0
-3
Other.dart
lib/userModel/page/Other.dart
+5
-0
UserPage.dart
lib/userModel/page/user/UserPage.dart
+32
-0
UserPageModel.dart
lib/userModel/page/user/UserPageModel.dart
+13
-0
UserRepository.dart
lib/userModel/service/UserRepository.dart
+27
-0
UserLocal.dart
lib/userModel/service/local/UserLocal.dart
+16
-0
UserRemote.dart
lib/userModel/service/remote/UserRemote.dart
+18
-0
UserLoginApi.dart
lib/userModel/service/remote/api/UserLoginApi.dart
+18
-0
UserLoginApi.serv.dart
lib/userModel/service/remote/api/UserLoginApi.serv.dart
+42
-0
UserEntity.dart
lib/userModel/service/remote/entity/UserEntity.dart
+92
-24
UserEntity.user.dart
lib/userModel/service/remote/entity/UserEntity.user.dart
+302
-0
UserUtil.user.dart
lib/userModel/user/UserUtil.user.dart
+0
-293
pubspec.lock
pubspec.lock
+3
-17
pubspec.yaml
pubspec.yaml
+5
-4
No files found.
.android/Flutter/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
View file @
2c0efeea
...
...
@@ -3,7 +3,6 @@ package io.flutter.plugins;
import
io.flutter.plugin.common.PluginRegistry
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.bigbug.mmkvflutter.MmkvFlutterPlugin
;
import
io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin
;
import
fleamarket.taobao.com.xservicekit.XserviceKitPlugin
;
/**
...
...
@@ -16,7 +15,6 @@ public final class GeneratedPluginRegistrant {
}
FlutterBoostPlugin
.
registerWith
(
registry
.
registrarFor
(
"com.taobao.idlefish.flutterboost.FlutterBoostPlugin"
));
MmkvFlutterPlugin
.
registerWith
(
registry
.
registrarFor
(
"com.bigbug.mmkvflutter.MmkvFlutterPlugin"
));
SharedPreferencesPlugin
.
registerWith
(
registry
.
registrarFor
(
"io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"
));
XserviceKitPlugin
.
registerWith
(
registry
.
registrarFor
(
"fleamarket.taobao.com.xservicekit.XserviceKitPlugin"
));
}
...
...
.android/app/build.gradle
View file @
2c0efeea
...
...
@@ -35,9 +35,9 @@ buildDir = new File(rootProject.projectDir, "../build/host")
dependencies
{
implementation
project
(
':flutter'
)
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
'com.android.support:appcompat-v7:2
8.0.0
'
implementation
'com.android.support:appcompat-v7:2
7.1.1
'
implementation
'com.android.support.constraint:constraint-layout:1.1.2'
implementation
'com.android.support:design:2
8.0.0
'
implementation
'com.android.support:design:2
7.1.1
'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation
'junit:junit:4.12'
...
...
.android/local.properties
View file @
2c0efeea
sdk.dir
=
/Users/apple/Library/Android/sdk
flutter.sdk
=
/Users/apple/Downloads/flutter
\ No newline at end of file
flutter.buildMode
=
debug
flutter.versionName
=
1.0.0
flutter.versionCode
=
1
\ No newline at end of file
.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.m
View file @
2c0efeea
...
...
@@ -5,7 +5,6 @@
#import "GeneratedPluginRegistrant.h"
#import <flutter_boost/FlutterBoostPlugin.h>
#import <mmkv_flutter/MmkvFlutterPlugin.h>
#import <shared_preferences/SharedPreferencesPlugin.h>
#import <xservice_kit/XserviceKitPlugin.h>
@implementation
GeneratedPluginRegistrant
...
...
@@ -13,7 +12,6 @@
+
(
void
)
registerWithRegistry
:(
NSObject
<
FlutterPluginRegistry
>*
)
registry
{
[
FlutterBoostPlugin
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"FlutterBoostPlugin"
]];
[
MmkvFlutterPlugin
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"MmkvFlutterPlugin"
]];
[
FLTSharedPreferencesPlugin
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"FLTSharedPreferencesPlugin"
]];
[
XserviceKitPlugin
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"XserviceKitPlugin"
]];
}
...
...
.ios/Flutter/FlutterPluginRegistrant/FlutterPluginRegistrant.podspec
View file @
2c0efeea
...
...
@@ -19,6 +19,5 @@ Depends on all your plugins, and provides a function to register them.
s
.
dependency
'Flutter'
s
.
dependency
'flutter_boost'
s
.
dependency
'mmkv_flutter'
s
.
dependency
'shared_preferences'
s
.
dependency
'xservice_kit'
end
build.yaml
View file @
2c0efeea
...
...
@@ -8,14 +8,14 @@ targets:
builders
:
user
:
import
:
"
package:gmalpha_flutter/Annotations/
RouterBuilde
r.dart"
import
:
"
package:gmalpha_flutter/Annotations/
ServiceGenerato
r.dart"
builder_factories
:
[
"
userBuilder"
]
build_extensions
:
{
'
.dart'
:
[
'
.user.dart'
]
}
auto_apply
:
root_package
build_to
:
source
Router
:
import
:
"
package:gmalpha_flutter/Annotations/
RouterBuilde
r.dart"
import
:
"
package:gmalpha_flutter/Annotations/
ServiceGenerato
r.dart"
builder_factories
:
[
"
routerBuilder"
]
build_extensions
:
{
'
.dart'
:
[
'
.rout.dart'
]
}
auto_apply
:
root_package
...
...
@@ -24,16 +24,24 @@ builders:
routerCenter
:
import
:
"
package:gmalpha_flutter/Annotations/
RouterBuilde
r.dart"
import
:
"
package:gmalpha_flutter/Annotations/
ServiceGenerato
r.dart"
builder_factories
:
[
"
routerCenterBuilder"
]
build_extensions
:
{
'
.dart'
:
[
'
.mark.dart'
]
}
auto_apply
:
root_package
build_to
:
source
# api_generator:
# import: "package:gmalpha_flutter/Annotations/RouterBuilder.dart"
# builder_factories: ["apiBuilder"]
# build_extensions: {".dart": ["api_generator.g.part"]}
api_generator
:
import
:
"
package:gmalpha_flutter/Annotations/ServiceGenerator.dart"
builder_factories
:
[
"
apiBuilder"
]
build_extensions
:
{
"
.dart"
:
[
"
.serv.dart"
]}
auto_apply
:
all_packages
build_to
:
source
applies_builders
:
[
"
source_gen|combining_builder"
]
#
# json:
# import: "package:gmalpha_flutter/Annotations/ServiceGenerator.dart"
# builder_factories: ["jsonBuilder"]
# build_extensions: {".dart": [".json.dart"]}
# auto_apply: all_packages
# build_to: source
# applies_builders: ["source_gen|combining_builder"]
...
...
lib/Annotations/Generator/ApiBuilderGenerator.dart
deleted
100644 → 0
View file @
29e28e7c
/*
* @author lsy
* @date 2019-09-03
**/
import
'dart:convert'
;
import
'package:analyzer/dart/element/element.dart'
;
import
'package:build/src/builder/build_step.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/RouterCenter.dart'
;
import
'package:source_gen/source_gen.dart'
;
import
'../RouterCenterRestore.dart'
;
class
ApiBuilderGenerator
extends
GeneratorForAnnotation
<
Request
>
{
@override
generateForAnnotatedElement
(
Element
element
,
ConstantReader
annotation
,
BuildStep
buildStep
)
{
print
(
"element is
$element
"
);
if
(
element
is
!
ClassElement
)
{
throw
InvalidGenerationSourceError
(
"Request class is not ok for
${element.displayName}
"
);
}
StringBuffer
stringBuffer
=
StringBuffer
(
""
);
for
(
var
methodElement
in
(
element
as
ClassElement
).
methods
)
{
for
(
var
annometadata
in
methodElement
.
metadata
)
{
final
metadata
=
annometadata
.
computeConstantValue
();
final
metadatatype
=
annometadata
.
runtimeType
;
print
(
"metadatatype is
$metadatatype
"
);
print
(
"metadata type is
${metadata.type.runtimeType}
"
);
if
(
metadata
.
type
.
name
==
"ApiMethod"
)
{
String
method
=
metadata
.
getField
(
"method"
).
toStringValue
();
String
url
=
metadata
.
getField
(
"url"
).
toStringValue
();
var
headerfield
=
metadata
.
getField
(
"head"
);
var
head
=
{};
if
(
headerfield
!=
null
)
{
print
(
"headerfield:
${headerfield.toMapValue()}
"
);
head
=
headerfield
.
toMapValue
().
map
((
key
,
value
)
=>
MapEntry
(
key
.
toStringValue
(),
value
.
toStringValue
()));
}
if
(
head
==
null
)
{
head
=
{};
}
head
[
"Content-Type"
]
=
"application/json"
;
print
(
"genertor is
${method}
"
);
print
(
"bool is
${method == "get"}
"
);
if
(
"get"
==
method
)
{
print
(
"get"
);
stringBuffer
.
write
(
_genGetAnnotation
(
url
,
methodElement
,
head
));
stringBuffer
.
writeln
();
}
else
if
(
"post"
==
method
)
{
print
(
"post"
);
stringBuffer
.
write
(
_genPostAnnotation
(
url
,
methodElement
,
head
));
stringBuffer
.
writeln
();
}
}
}
}
return
stringBuffer
.
toString
();
}
String
_genGetAnnotation
(
String
url
,
MethodElement
element
,
Map
head
)
{
return
"""
Future _
\
$get_${element.name}
() {
${_getHeadMapString(head)}
return http.get("
$url
",headers:header);
}
"""
;
}
String
_genPostAnnotation
(
String
url
,
MethodElement
element
,
Map
head
)
{
return
"""
Future _
\
$post_${element.name}
() {
${_getHeadMapString(head)}
return http.post("
$
{
url
}
",headers:header);
}
"""
;
}
String
_getHeadMapString
(
Map
head
)
{
return
"""
var header =
${jsonEncode(head)}
;
"""
;
}
}
class
Request
{
const
Request
();
}
class
ApiMethod
{
final
String
url
;
final
String
method
;
final
Map
head
;
const
ApiMethod
(
this
.
url
,
this
.
method
,{
this
.
head
});
}
class
HttpRequestType
{
static
const
String
GET
=
"get"
;
static
const
String
POST
=
"post"
;
}
lib/Annotations/Generator/ServiceGenerator.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-03
**/
import
'dart:convert'
;
import
'dart:core'
;
import
'dart:math'
;
import
'package:analyzer/dart/element/element.dart'
;
import
'package:build/src/builder/build_step.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart'
;
import
'package:source_gen/source_gen.dart'
;
import
'../RouterCenterRestore.dart'
;
class
ServiceGenerator
extends
GeneratorForAnnotation
<
ServiceCenter
>
{
@override
generateForAnnotatedElement
(
Element
element
,
ConstantReader
annotation
,
BuildStep
buildStep
)
{
print
(
"element is
$element
"
);
if
(
element
is
!
ClassElement
)
{
throw
InvalidGenerationSourceError
(
"Request class is not ok for
${element.displayName}
"
);
}
StringBuffer
improtBuffer
=
new
StringBuffer
();
StringBuffer
methodBuffer
=
StringBuffer
(
""
);
StringBuffer
mapBuffer
=
new
StringBuffer
();
List
<
String
>
differentList
=
[];
for
(
var
methodElement
in
(
element
as
ClassElement
).
methods
)
{
for
(
var
annometadata
in
methodElement
.
metadata
)
{
final
metadata
=
annometadata
.
computeConstantValue
();
if
(
metadata
.
type
.
name
==
"Post"
||
metadata
.
type
.
name
==
"Get"
)
{
if
(!
differentList
.
contains
(
methodElement
.
returnType
.
name
))
{
var
pathSegments
=
buildStep
.
inputId
.
pathSegments
;
StringBuffer
path
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
pathSegments
.
length
;
i
++)
{
if
(
i
<
pathSegments
.
length
-
2
&&
pathSegments
[
i
]
!=
"lib"
)
{
path
.
write
(
"
${pathSegments[i]}
/"
);
}
}
improtBuffer
.
write
(
"import 'package:
${buildStep.inputId.package}
/
${path.toString()}
entity/
${methodElement.returnType.name}
.dart
\'
;
\n
"
);
differentList
.
add
(
methodElement
.
returnType
.
name
);
}
String
tempParams
;
String
sendType
=
metadata
.
type
.
name
==
"Post"
?
"post"
:
"get"
;
mapBuffer
.
write
(
"""
return Observable.fromFuture(DioUtil().
${sendType}
(
\'
${metadata.getField("sufUrl").toStringValue()}
\'
,data:{
"""
);
bool
needMap
=
false
;
for
(
int
i
=
0
;
i
<
methodElement
.
parameters
.
length
;
i
++)
{
var
paramsMeta
=
methodElement
.
parameters
[
i
];
for
(
int
j
=
0
;
j
<
paramsMeta
.
metadata
.
length
;
j
++)
{
var
parameter
=
paramsMeta
.
metadata
[
j
];
final
queryAnno
=
parameter
.
computeConstantValue
();
if
(
queryAnno
.
type
.
name
==
"Query"
)
{
needMap
=
true
;
if
(
tempParams
==
null
)
{
tempParams
=
"
${paramsMeta}
"
;
}
else
{
tempParams
=
"
${tempParams}
,
${paramsMeta}
"
;
}
if
(
i
==
methodElement
.
parameters
.
length
-
1
)
{
mapBuffer
.
write
(
"
\'
${queryAnno.getField("params").toStringValue()}
\'
:
${paramsMeta.name}
"
);
}
else
{
mapBuffer
.
write
(
"
\'
${queryAnno.getField("params").toStringValue()}
\'
:
${paramsMeta.name}
,"
);
}
}
}
}
mapBuffer
.
write
(
"}))"
);
mapBuffer
.
write
(
"""
.map((value){
if(value.statusCode==200){
Map map = json.decode(value.toString());
return
${methodElement.returnType.name}
.fromJson(map);
}else{
throw HttpException("
statusCode
error
:
\$
{
value
.
statusCode
}
");
}
});
"""
);
methodBuffer
.
write
(
"""
Observable<
${methodElement.returnType.name}
>
${methodElement.name}
(
${tempParams == null ? "" : tempParams}
){
${mapBuffer.toString()}
}
"""
);
mapBuffer
.
clear
();
}
}
}
return
"""
import 'dart:convert';
\n
import 'dart:io';
\n
import 'package:rxdart/rxdart.dart';
\n
${improtBuffer.toString()}
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
\n
class
${element.displayName}
Impl{
${methodBuffer.toString()}
}
"""
;
}
}
lib/Annotations/Generator/UserGenerator.dart
View file @
2c0efeea
...
...
@@ -19,6 +19,7 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
@override
generateForAnnotatedElement
(
Element
element
,
ConstantReader
annotation
,
BuildStep
buildStep
)
{
StringBuffer
buffer
=
new
StringBuffer
();
for
(
var
fieldData
in
(
element
as
ClassElement
).
fields
)
{
for
(
var
annometadata
in
fieldData
.
metadata
)
{
...
...
@@ -26,17 +27,21 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
// final metadatatype = annometadata.runtimeType;
// print("metadatatype is $metadatatype");
// print("metadataNAME is ${metadata.type.name}");
// print("element is $element");
if
(
element
is
!
ClassElement
)
{
throw
InvalidGenerationSourceError
(
"Request class is not ok for
${element.displayName}
"
);
}
if
(
metadata
.
type
.
name
==
"User"
)
{
String
key
=
metadata
.
getField
(
"key"
).
toStringValue
();
var
field
=
metadata
.
getField
(
"type"
);
var
type
=
field
.
type
.
name
;
var
runtimeType
=
field
.
runtimeType
;
if
(
type
==
"String"
)
{
buffer
.
write
(
"""
String _
${fieldData.name}
;
Observable<bool> save
${fieldData.name}
(String
${fieldData.name}
){
return Observable.fromFuture(saveStringKv("
$
{
key
}
",
${fieldData.name}
))
return Observable.fromFuture(
mmKvUtil.
saveStringKv("
$
{
key
}
",
${fieldData.name}
))
.map((value){
if(value){
this._
${fieldData.name}
=
${fieldData.name}
;
...
...
@@ -48,14 +53,14 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_
${fieldData.name}
!=null){
return Observable.fromFuture(Future.value(_
${fieldData.name}
));
}
return Observable.fromFuture(getStringKv("
$
{
key
}
"));
return Observable.fromFuture(
mmKvUtil.
getStringKv("
$
{
key
}
"));
}
"""
);
}
else
if
(
type
==
"int"
)
{
buffer
.
write
(
"""
int _
${fieldData.name}
;
Observable<bool> save
${fieldData.name}
(int
${fieldData.name}
){
return Observable.fromFuture(saveIntKv("
$
{
key
}
",
${fieldData.name}
))
return Observable.fromFuture(
mmKvUtil.
saveIntKv("
$
{
key
}
",
${fieldData.name}
))
.map((value){
if(value){
this._
${fieldData.name}
=
${fieldData.name}
;
...
...
@@ -67,14 +72,14 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_
${fieldData.name}
!=null){
return Observable.fromFuture(Future.value(_
${fieldData.name}
));
}
return Observable.fromFuture(getIntKv("
$
{
key
}
"));
return Observable.fromFuture(
mmKvUtil.
getIntKv("
$
{
key
}
"));
}
"""
);
}
else
if
(
type
==
"double"
)
{
buffer
.
write
(
"""
double _
${fieldData.name}
;
Observable<bool> save
${fieldData.name}
(double
${fieldData.name}
){
return Observable.fromFuture(saveDoubleKv("
$
{
key
}
",
${fieldData.name}
))
return Observable.fromFuture(
mmKvUtil.
saveDoubleKv("
$
{
key
}
",
${fieldData.name}
))
.map((value){
if(value){
this._
${fieldData.name}
=
${fieldData.name}
;
...
...
@@ -86,14 +91,14 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_
${fieldData.name}
!=null){
return Observable.fromFuture(Future.value(_
${fieldData.name}
));
}
return Observable.fromFuture(getDoubleKv("
$
{
key
}
"));
return Observable.fromFuture(
mmKvUtil.
getDoubleKv("
$
{
key
}
"));
}
"""
);
}
else
if
(
type
==
"bool"
)
{
buffer
.
write
(
"""
bool _
${fieldData.name}
;
Observable<bool> save
${fieldData.name}
(bool
${fieldData.name}
){
return Observable.fromFuture(saveBoolKv("
$
{
key
}
",
${fieldData.name}
))
return Observable.fromFuture(
mmKvUtil.
saveBoolKv("
$
{
key
}
",
${fieldData.name}
))
.map((value){
if(value){
this._
${fieldData.name}
=
${fieldData.name}
;
...
...
@@ -105,7 +110,7 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_
${fieldData.name}
!=null){
return Observable.fromFuture(Future.value(_
${fieldData.name}
));
}
return Observable.fromFuture(getBoolKv("
$
{
key
}
"));
return Observable.fromFuture(
mmKvUtil.
getBoolKv("
$
{
key
}
"));
}
"""
);
}
...
...
@@ -117,18 +122,18 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
import 'package:rxdart/rxdart.dart';
import 'package:
${buildStep.inputId.package}
/commonModel/app_module.dart';
class
UserCenter
Impl{
class
${element.displayName}
Impl{
factory
UserCenter
Impl() => _sharedInstance();
factory
${element.displayName}
Impl() => _sharedInstance();
static
UserCenter
Impl _instance;
static
${element.displayName}
Impl _instance;
UserCenter
Impl._() {
${element.displayName}
Impl._() {
}
static
UserCenter
Impl _sharedInstance() {
static
${element.displayName}
Impl _sharedInstance() {
if (_instance == null) {
_instance =
UserCenter
Impl._();
_instance =
${element.displayName}
Impl._();
}
return _instance;
}
...
...
lib/Annotations/
RouterBuilde
r.dart
→
lib/Annotations/
ServiceGenerato
r.dart
View file @
2c0efeea
import
'package:gmalpha_flutter/Annotations/Generator/
ApiBuilder
Generator.dart'
;
import
'package:gmalpha_flutter/Annotations/Generator/
Service
Generator.dart'
;
import
'package:gmalpha_flutter/Annotations/Generator/UserGenerator.dart'
;
import
'package:source_gen/source_gen.dart'
;
import
'package:build/src/builder/builder.dart'
;
...
...
@@ -16,7 +16,9 @@ Builder routerCenterBuilder(BuilderOptions options) =>
Builder
userBuilder
(
BuilderOptions
options
)=>
LibraryBuilder
(
UserGenerator
(),
generatedExtension:
".user.dart"
);
Builder
apiBuilder
(
BuilderOptions
options
)
{
print
(
"xxxx"
);
return
SharedPartBuilder
([
ApiBuilderGenerator
()],
"api_generator"
);
}
Builder
apiBuilder
(
BuilderOptions
options
)=>
LibraryBuilder
(
ServiceGenerator
(),
generatedExtension:
".serv.dart"
);
//Builder jsonBuilder(BuilderOptions options)=>
// LibraryBuilder(JsonSerializableGenerator(),generatedExtension: ".json.dart");
\ No newline at end of file
lib/Annotations/anno/Get.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
library
Get
;
class
Get
{
final
String
sufUrl
;
const
Get
(
this
.
sufUrl
);
}
lib/Annotations/anno/Post.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
library
Post
;
class
Post
{
final
String
sufUrl
;
const
Post
(
this
.
sufUrl
);
}
lib/Annotations/anno/Query.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
library
Query
;
class
Query
{
final
String
params
;
const
Query
(
this
.
params
);
}
lib/Annotations/anno/ServiceCenter.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
library
ServiceCenter
;
class
ServiceCenter
{
const
ServiceCenter
();
}
\ No newline at end of file
lib/commonModel/app_module.dart
View file @
2c0efeea
import
'package:gmalpha_flutter/userModel/user/UserUtil.user.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:mmkv_flutter/mmkv_flutter.dart'
;
import
'package:gmalpha_flutter/commonModel/mmkv/MmkvUtil.dart'
;
Mm
kvFlutter
_mmkv
;
Mm
KvUtil
mmKvUtil
;
applicationInit
()
async
{
_mmkv
=
await
MmkvFlutter
.
getInstance
();
mmKvUtil
=
await
MmKvUtil
.
getInstance
();
}
Future
saveBoolKv
(
String
key
,
bool
value
)
async
{
return
await
_mmkv
.
setBool
(
key
,
value
);
}
Future
saveStringKv
(
String
key
,
String
value
)
async
{
return
await
_mmkv
.
setString
(
key
,
value
);
}
Future
saveDoubleKv
(
String
key
,
double
value
)
async
{
return
await
_mmkv
.
setDouble
(
key
,
value
);
}
Future
<
bool
>
saveIntKv
(
String
key
,
int
value
)
async
{
return
await
_mmkv
.
setInt
(
key
,
value
);
}
Future
<
String
>
getStringKv
(
String
key
)
async
{
return
await
_mmkv
.
getString
(
key
);
}
Future
<
bool
>
getBoolKv
(
String
key
)
async
{
return
await
_mmkv
.
getBool
(
key
);
}
Future
<
int
>
getIntKv
(
String
key
)
async
{
return
await
_mmkv
.
getInt
(
key
);
}
Future
<
double
>
getDoubleKv
(
String
key
)
async
{
return
await
_mmkv
.
getDouble
(
key
);
}
Future
<
bool
>
clearKv
()
async
{
return
await
_mmkv
.
clear
();
}
lib/commonModel/bloc/bloc_base.dart
0 → 100644
View file @
2c0efeea
abstract
class
BlocBase
{
void
dispose
();
}
lib/commonModel/bloc/bloc_provider.dart
0 → 100644
View file @
2c0efeea
import
'package:flutter/widgets.dart'
;
import
'bloc_base.dart'
;
Type
_typeOf
<
T
>()
=>
T
;
class
BlocProvider
<
T
extends
BlocBase
>
extends
StatefulWidget
{
BlocProvider
({
Key
key
,
@required
this
.
child
,
@required
this
.
blocs
,
})
:
super
(
key:
key
);
final
Widget
child
;
final
List
<
T
>
blocs
;
@override
_BlocProviderState
<
T
>
createState
()
=>
_BlocProviderState
<
T
>();
static
List
<
T
>
of
<
T
extends
BlocBase
>(
BuildContext
context
)
{
final
type
=
_typeOf
<
_BlocProviderInherited
<
T
>>();
_BlocProviderInherited
<
T
>
provider
=
context
.
ancestorInheritedElementForWidgetOfExactType
(
type
)?.
widget
;
return
provider
?.
blocs
;
}
}
class
_BlocProviderState
<
T
extends
BlocBase
>
extends
State
<
BlocProvider
<
T
>>
{
@override
void
dispose
()
{
widget
.
blocs
.
map
((
bloc
)
{
bloc
.
dispose
();
});
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
_BlocProviderInherited
<
T
>(
blocs:
widget
.
blocs
,
child:
widget
.
child
,
);
}
}
class
_BlocProviderInherited
<
T
>
extends
InheritedWidget
{
_BlocProviderInherited
({
Key
key
,
@required
Widget
child
,
@required
this
.
blocs
,
})
:
super
(
key:
key
,
child:
child
);
final
List
<
T
>
blocs
;
@override
bool
updateShouldNotify
(
_BlocProviderInherited
oldWidget
)
=>
false
;
}
lib/commonModel/mmkv/MmkvUtil.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
import
'package:mmkv_flutter/mmkv_flutter.dart'
;
class
MmKvUtil
{
static
MmkvFlutter
_mmkv
;
static
MmKvUtil
mmKvUtil
;
MmKvUtil
.
_
(
MmkvFlutter
mmkv
)
{
_mmkv
=
mmkv
;
}
static
Future
<
MmKvUtil
>
getInstance
()
async
{
if
(
mmKvUtil
==
null
)
{
final
MmkvFlutter
_mmkv
=
await
MmkvFlutter
.
getInstance
();
mmKvUtil
=
new
MmKvUtil
.
_
(
_mmkv
);
}
return
mmKvUtil
;
}
Future
saveBoolKv
(
String
key
,
bool
value
)
async
{
return
await
_mmkv
.
setBool
(
key
,
value
);
}
Future
saveStringKv
(
String
key
,
String
value
)
async
{
return
await
_mmkv
.
setString
(
key
,
value
);
}
Future
saveDoubleKv
(
String
key
,
double
value
)
async
{
return
await
_mmkv
.
setDouble
(
key
,
value
);
}
Future
<
bool
>
saveIntKv
(
String
key
,
int
value
)
async
{
return
await
_mmkv
.
setInt
(
key
,
value
);
}
Future
<
String
>
getStringKv
(
String
key
)
async
{
return
await
_mmkv
.
getString
(
key
);
}
Future
<
bool
>
getBoolKv
(
String
key
)
async
{
return
await
_mmkv
.
getBool
(
key
);
}
Future
<
int
>
getIntKv
(
String
key
)
async
{
return
await
_mmkv
.
getInt
(
key
);
}
Future
<
double
>
getDoubleKv
(
String
key
)
async
{
return
await
_mmkv
.
getDouble
(
key
);
}
Future
<
bool
>
clearKv
()
async
{
return
await
_mmkv
.
clear
();
}
}
lib/commonModel/net/DioUtil.dart
View file @
2c0efeea
...
...
@@ -11,7 +11,8 @@ class BaseResp<T> {
T
extra
;
T
userType
;
BaseResp
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
,
this
.
extra
,
this
.
userType
);
BaseResp
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
,
this
.
extra
,
this
.
userType
);
@override
String
toString
()
{
...
...
@@ -37,7 +38,8 @@ class BaseRespR<T> {
T
userType
;
Response
response
;
BaseRespR
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
,
this
.
extra
,
this
.
userType
,
this
.
response
);
BaseRespR
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
,
this
.
extra
,
this
.
userType
,
this
.
response
);
@override
String
toString
()
{
...
...
@@ -49,7 +51,8 @@ class BaseRespR<T> {
sb
.
write
(
",
\"
extra
\"
:
\"
$extra
\"
"
);
sb
.
write
(
",
\"
userType
\"
:
\"
$userType
\"
"
);
sb
.
write
(
'}'
);
return
sb
.
toString
();;
return
sb
.
toString
();
;
}
}
...
...
@@ -104,6 +107,7 @@ class HttpConfig {
/// 详细使用请查看dio官网 https://github.com/flutterchina/dio/blob/flutter/README-ZH.md#Https证书校验.
/// PKCS12 证书密码.
String
pKCSPwd
;
//缓存
Map
nativeCookie
;
}
...
...
@@ -160,6 +164,21 @@ class DioUtil {
DioUtil
.
_init
()
{
_dio
=
new
Dio
(
_options
);
//TODO
_dio
.
interceptors
.
add
(
InterceptorsWrapper
(
onRequest:
(
RequestOptions
options
)
{
print
(
"请求之前"
);
// Do something before request is sent
return
options
;
//continue
},
onResponse:
(
Response
response
)
{
print
(
"响应之前"
);
// Do something with response data
return
response
;
// continue
},
onError:
(
DioError
e
)
{
print
(
"错误之前"
);
// Do something with response error
return
e
;
//continue
}));
}
/// 打开debug模式.
...
...
@@ -179,33 +198,114 @@ class DioUtil {
if
(
_dio
!=
null
)
{
_dio
.
options
=
_options
;
(
_dio
.
httpClientAdapter
as
DefaultHttpClientAdapter
).
onHttpClientCreate
=
(
client
)
{
client
.
findProxy
=
(
url
)
{
return
_isDebug
?
'PROXY
$_proxy
'
:
'DIRECT'
;
};
};
if
(
_pem
!=
null
)
{
// httpClientAdapter
(
_dio
.
httpClientAdapter
as
DefaultHttpClientAdapter
).
onHttpClientCreate
=
(
client
)
{
client
.
badCertificateCallback
=
(
X509Certificate
cert
,
String
host
,
int
port
)
{
if
(
cert
.
pem
==
_pem
)
{
// 证书一致,则放行
return
true
;
}
return
false
;
};
};
}
if
(
_pKCSPath
!=
null
)
{
(
_dio
.
httpClientAdapter
as
DefaultHttpClientAdapter
).
onHttpClientCreate
=
(
client
)
{
SecurityContext
sc
=
new
SecurityContext
();
//file为证书路径
sc
.
setTrustedCertificates
(
_pKCSPath
,
password:
_pKCSPwd
);
HttpClient
httpClient
=
new
HttpClient
(
context:
sc
);
return
httpClient
;
};
// (_dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
// client.findProxy = (url) {
// return _isDebug ? 'PROXY $_proxy' : 'DIRECT';
// };
// };
// if (_pem != null) {
// // httpClientAdapter
// (_dio.httpClientAdapter as DefaultHttpClientAdapter)
// .onHttpClientCreate = (client) {
// client.badCertificateCallback =
// (X509Certificate cert, String host, int port) {
// if (cert.pem == _pem) {
// // 证书一致,则放行
// return true;
// }
// return false;
// };
// };
// }
// if (_pKCSPath != null) {
// (_dio.httpClientAdapter as DefaultHttpClientAdapter)
// .onHttpClientCreate = (client) {
// SecurityContext sc = new SecurityContext();
// //file为证书路径
// sc.setTrustedCertificates(_pKCSPath, password: _pKCSPwd);
// HttpClient httpClient = new HttpClient(context: sc);
// return httpClient;
// };
// }
}
}
/*
* get请求
*/
Future
<
Response
>
get
(
url
,
{
data
,
options
,
cancelToken
})
async
{
Response
response
;
try
{
response
=
await
_dio
.
get
(
url
,
queryParameters:
data
,
options:
options
,
cancelToken:
cancelToken
);
// print('get success---------${response.statusCode}');
// print('get success---------${response.data}');
_printHttpLog
(
response
);
// response.data; 响应体
// response.headers; 响应头
// response.request; 请求体
// response.statusCode; 状态码
}
on
DioError
catch
(
e
)
{
print
(
'get error---------
$e
'
);
formatError
(
e
);
}
return
response
;
}
/*
* post请求
*/
post
(
url
,
{
data
,
options
,
cancelToken
})
async
{
Response
response
;
try
{
response
=
await
_dio
.
post
(
url
,
queryParameters:
data
,
options:
options
,
cancelToken:
cancelToken
);
print
(
'post success---------
${response.data}
'
);
}
on
DioError
catch
(
e
)
{
print
(
'post error---------
$e
'
);
formatError
(
e
);
}
return
response
;
}
/*
* 下载文件
*/
downloadFile
(
urlPath
,
savePath
)
async
{
Response
response
;
try
{
response
=
await
_dio
.
download
(
urlPath
,
savePath
,
onReceiveProgress:
(
int
count
,
int
total
)
{
//进度
print
(
"
$count
$total
"
);
});
print
(
'downloadFile success---------
${response.data}
'
);
}
on
DioError
catch
(
e
)
{
print
(
'downloadFile error---------
$e
'
);
formatError
(
e
);
}
return
response
.
data
;
}
void
formatError
(
DioError
e
)
{
if
(
e
.
type
==
DioErrorType
.
CONNECT_TIMEOUT
)
{
// It occurs when url is opened timeout.
print
(
"连接超时"
);
}
else
if
(
e
.
type
==
DioErrorType
.
SEND_TIMEOUT
)
{
// It occurs when url is sent timeout.
print
(
"请求超时"
);
}
else
if
(
e
.
type
==
DioErrorType
.
RECEIVE_TIMEOUT
)
{
//It occurs when receiving timeout
print
(
"响应超时"
);
}
else
if
(
e
.
type
==
DioErrorType
.
RESPONSE
)
{
// When the server response, but with a incorrect status, such as 404, 503...
print
(
"出现异常"
);
}
else
if
(
e
.
type
==
DioErrorType
.
CANCEL
)
{
// When the request is cancelled, dio will throw a error with this type.
print
(
"请求取消"
);
}
else
{
//DEFAULT Default error type, Some other Error. In this case, you can read the DioError.error if it is not null.
print
(
"未知错误"
);
}
}
...
...
@@ -217,7 +317,10 @@ class DioUtil {
/// Map<String, dynamic> queryParameters,
/// <BaseResp<T> 返回 status code msg data .
Future
<
BaseResp
<
T
>>
request
<
T
>(
String
method
,
String
path
,
{
Map
<
String
,
dynamic
>
queryParameters
,
data
,
Options
options
,
CancelToken
cancelToken
})
async
{
{
Map
<
String
,
dynamic
>
queryParameters
,
data
,
Options
options
,
CancelToken
cancelToken
})
async
{
// _dio.request(path, que)
// _dio.request(path, )
Response
response
=
await
_dio
.
request
(
path
,
...
...
@@ -254,6 +357,8 @@ class DioUtil {
_extra
=
response
.
data
[
_extraKey
];
_userType
=
response
.
data
[
_userType
];
}
print
(
"------ MSG
${_msg}
DATA
${_data}
EXTRA
${_extra}
USERTYPE
${_userType}
"
);
return
new
BaseResp
(
_status
,
_code
,
_msg
,
_data
,
_extra
,
_userType
);
}
catch
(
e
)
{
return
new
Future
.
error
(
new
DioError
(
...
...
@@ -278,7 +383,10 @@ class DioUtil {
/// [options] The request options.
/// <BaseRespR<T> 返回 status code msg data Response.
Future
<
BaseRespR
<
T
>>
requestR
<
T
>(
String
method
,
String
path
,
{
Map
<
String
,
dynamic
>
queryParameters
,
data
,
Options
options
,
CancelToken
cancelToken
})
async
{
{
Map
<
String
,
dynamic
>
queryParameters
,
data
,
Options
options
,
CancelToken
cancelToken
})
async
{
// _dio.request(path,queryParameters: )
Response
response
=
await
_dio
.
request
(
path
,
data:
data
,
...
...
@@ -313,7 +421,8 @@ class DioUtil {
_extra
=
response
.
data
[
_extraKey
];
_userType
=
response
.
data
[
_userType
];
}
return
new
BaseRespR
(
_status
,
_code
,
_msg
,
_data
,
_extra
,
_userType
,
response
);
return
new
BaseRespR
(
_status
,
_code
,
_msg
,
_data
,
_extra
,
_userType
,
response
);
}
catch
(
e
)
{
return
new
Future
.
error
(
new
DioError
(
response:
response
,
...
...
@@ -344,9 +453,7 @@ class DioUtil {
Options
options
,
})
{
return
_dio
.
download
(
urlPath
,
savePath
,
cancelToken:
cancelToken
,
data:
data
,
options:
options
);
cancelToken:
cancelToken
,
data:
data
,
options:
options
);
}
/// decode response data.
...
...
@@ -412,8 +519,7 @@ class DioUtil {
/// get Options Str.
String
_getOptionsStr
(
Options
request
)
{
return
"method: "
+
request
.
method
;
return
"method: "
+
request
.
method
;
}
/// print Data Str.
...
...
@@ -446,11 +552,16 @@ class DioUtil {
BaseOptions
options
=
BaseOptions
();
options
.
connectTimeout
=
10
*
1000
;
options
.
receiveTimeout
=
20
*
1000
;
options
.
contentType
=
ContentType
.
parse
(
'application/x-www-form-urlencoded'
);
// options.contentType = ContentType.parse('application/x-www-form-urlencoded');
options
.
contentType
=
ContentType
.
json
;
options
.
responseType
=
ResponseType
.
plain
;
// options.baseUrl = 'https://earth.iyanzhi.com/';
options
.
baseUrl
=
'http://earth.gmapp.env/'
;
// options.baseUrl = 'http://earth.gmapp.env/';
options
.
baseUrl
=
"https://www.wanandroid.com/"
;
Map
<
String
,
dynamic
>
headers
=
Map
<
String
,
dynamic
>();
headers
[
'Accept'
]
=
'application/json'
;
headers
[
'version'
]
=
'1.0.0'
;
options
.
headers
=
headers
;
return
options
;
}
}
lib/main.dart
View file @
2c0efeea
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart'
;
...
...
@@ -6,7 +8,6 @@ import 'package:gmalpha_flutter/commonModel/ui/ALColors.dart';
import
'package:gmalpha_flutter/commonModel/net/DioUtil.dart'
;
import
'package:dio/dio.dart'
;
import
'package:gmalpha_flutter/messageModel/home/message_home.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'comment_suggest.dart'
;
...
...
@@ -43,6 +44,8 @@ class _MyAppState extends State<MyApp> {
DioUtil
().
setConfig
(
config
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
...
...
lib/userModel/UserRouter.dart
View file @
2c0efeea
...
...
@@ -10,6 +10,4 @@ import 'package:gmalpha_flutter/userModel/UserRouterImpl.dart';
@Router
(
"userModel"
,
UserRouterImpl
)
abstract
class
UserRouter
implements
RouterBaser
{
}
\ No newline at end of file
lib/userModel/UserRouterImpl.dart
View file @
2c0efeea
...
...
@@ -6,6 +6,4 @@ import 'package:gmalpha_flutter/userModel/UserRouter.dart';
class
UserRouterImpl
implements
UserRouter
{
}
\ No newline at end of file
lib/userModel/page/Other.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
\ No newline at end of file
lib/userModel/page/user/UserPage.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/userModel/page/user/UserPageModel.dart'
;
class
UserWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
=>
UserState
();
}
class
UserState
extends
State
<
UserWidget
>
{
UserPageModel
_model
;
@override
void
initState
()
{
super
.
initState
();
_model
=
new
UserPageModel
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
ALRootInheritWideget
(
model:
_model
,
child:
Center
(
child:
Text
(
_model
.
text
),
),
));
}
}
lib/userModel/page/user/UserPageModel.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
class
UserPageModel
{
String
text
;
}
lib/userModel/service/UserRepository.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
import
'package:gmalpha_flutter/userModel/service/local/UserLocal.dart'
;
import
'package:gmalpha_flutter/userModel/service/remote/UserRemote.dart'
;
class
UserRepository
{
UserRemote
_remote
;
UserLocal
_local
;
static
UserRepository
_userRepository
;
UserRepository
.
_
()
{
_remote
=
UserRemote
.
getInstance
();
_local
=
UserLocal
.
getInstance
();
}
static
UserRepository
getInstance
()
{
if
(
_userRepository
==
null
)
{
_userRepository
=
UserRepository
.
_
();
}
return
_userRepository
;
}
}
lib/userModel/service/local/UserLocal.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
class
UserLocal
{
static
UserLocal
_userRemote
;
UserLocal
.
_
()
{}
static
UserLocal
getInstance
()
{
if
(
_userRemote
==
null
)
{
_userRemote
=
new
UserLocal
.
_
();
}
return
_userRemote
;
}
}
lib/userModel/service/remote/UserRemote.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
class
UserRemote
{
static
UserRemote
_userRemote
;
UserRemote
.
_
()
{}
static
UserRemote
getInstance
()
{
if
(
_userRemote
==
null
)
{
_userRemote
=
new
UserRemote
.
_
();
}
return
_userRemote
;
}
}
lib/userModel/service/remote/api/UserLoginApi.dart
0 → 100644
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-04
**/
import
'package:gmalpha_flutter/Annotations/anno/Get.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/Post.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/Query.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart'
;
import
'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart'
;
@ServiceCenter
()
abstract
class
UserLoginApi
{
@Post
(
"user/login"
)
UserEntity
login
(
@Query
(
"name"
)
String
name
,
@Query
(
"word"
)
String
word
);
@Get
(
"user/info"
)
UserEntity
getUserInfo
(
@Query
(
"token"
)
String
token
);
}
lib/userModel/service/remote/api/UserLoginApi.serv.dart
0 → 100644
View file @
2c0efeea
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// ServiceGenerator
// **************************************************************************
import
'dart:convert'
;
import
'dart:io'
;
import
'package:rxdart/rxdart.dart'
;
import
'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart'
;
import
'package:gmalpha_flutter/commonModel/net/DioUtil.dart'
;
class
UserLoginApiImpl
{
Observable
<
UserEntity
>
login
(
String
name
,
String
word
)
{
return
Observable
.
fromFuture
(
DioUtil
().
post
(
'user/login'
,
data:
{
'name'
:
name
,
'word'
:
word
}))
.
map
((
value
)
{
if
(
value
.
statusCode
==
200
)
{
Map
map
=
json
.
decode
(
value
.
toString
());
return
UserEntity
.
fromJson
(
map
);
}
else
{
throw
HttpException
(
"statusCode error :
${value.statusCode}
"
);
}
});
}
Observable
<
UserEntity
>
getUserInfo
(
String
token
)
{
return
Observable
.
fromFuture
(
DioUtil
().
get
(
'user/info'
,
data:
{
'token'
:
token
})).
map
((
value
)
{
if
(
value
.
statusCode
==
200
)
{
Map
map
=
json
.
decode
(
value
.
toString
());
return
UserEntity
.
fromJson
(
map
);
}
else
{
throw
HttpException
(
"statusCode error :
${value.statusCode}
"
);
}
});
}
}
lib/userModel/
user/UserUtil
.dart
→
lib/userModel/
service/remote/entity/UserEntity
.dart
View file @
2c0efeea
/*
* @author lsy
* @date 2019-09-03
**/
import
'package:gmalpha_flutter/Annotations/anno/User.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/UserCenter.dart'
;
import
'package:json_annotation/json_annotation.dart'
;
const
String
USER_ID
=
"user_uid"
;
const
String
NICKNAME
=
"username"
;
...
...
@@ -21,72 +18,143 @@ const String COUNTRY_LANGUAGE = "country_language";
const
String
COUNTRY_NAME
=
"country_name"
;
@UserCenter
()
class
UserUtil
{
class
UserEntity
{
/**
* 用户id
*/
@User
(
USER_ID
,
""
)
String
User_i
d
;
String
userI
d
;
/**
* 用户昵称
*/
@User
(
NICKNAME
,
""
)
String
nick
_n
ame
;
String
nick
N
ame
;
/**
* 用户头像
*/
@User
(
PORTRAIT
,
""
)
String
profile
_p
ic
;
String
profile
P
ic
;
/**
* 是否需要答题
*/
@User
(
PERSONAL_QA
,
true
)
bool
has
_a
nswered
=
true
;
bool
has
A
nswered
=
true
;
/**
* 是否扫过脸
*/
@User
(
HAS_SCAN_FACE
,
true
)
bool
has
_scan_f
ace
=
false
;
bool
has
ScanF
ace
=
false
;
String
id
;
@User
(
GENDER
,
""
)
String
gender
;
@User
(
CURRENT_CITY_ID
,
""
)
String
city
_i
d
;
String
city
I
d
;
@User
(
BIRTHDAY
,
0
)
int
birth
;
@User
(
COUNTRY_ID
,
""
)
String
country
_i
d
;
String
country
I
d
;
bool
logined
;
// 用户是否设置过个人信息
@User
(
DETAIL_SETTED
,
true
)
bool
detail
_s
etted
=
true
;
bool
detail
S
etted
=
true
;
//用户是否选择了标签
bool
tag
_s
etted
=
false
;
bool
tag
S
etted
=
false
;
//注册流程中断后返回之前的登录页面
@User
(
QUESTION_URL
,
""
)
String
question
_u
rl
;
String
question
U
rl
;
@User
(
USER_BIND_MOBILE
,
true
)
bool
is
_b
ind
;
bool
is
B
ind
;
@User
(
COUNTRY_NAME
,
""
)
String
country
_info_n
ame
;
String
country
InfoN
ame
;
@User
(
COUNTRY_ID
,
""
)
String
country
_info_i
d
;
String
country
InfoI
d
;
@User
(
COUNTRY_LANGUAGE
,
""
)
String
country_info_language
;
String
countryInfoLanguage
;
String
insBindId
;
String
registerTime
;
UserEntity
(
{
this
.
userId
,
this
.
nickName
,
this
.
profilePic
,
this
.
hasAnswered
,
this
.
hasScanFace
,
this
.
id
,
this
.
gender
,
this
.
cityId
,
this
.
birth
,
this
.
countryId
,
this
.
logined
,
this
.
detailSetted
,
this
.
tagSetted
,
this
.
questionUrl
,
this
.
isBind
,
this
.
countryInfoName
,
this
.
countryInfoId
,
this
.
countryInfoLanguage
,
this
.
insBindId
,
this
.
registerTime
});
UserEntity
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
userId
=
json
[
'user_id'
];
nickName
=
json
[
'nick_name'
];
profilePic
=
json
[
'profile_pic'
];
hasAnswered
=
json
[
'has_answered'
];
hasScanFace
=
json
[
'has_scan_face'
];
id
=
json
[
'id'
];
gender
=
json
[
'gender'
];
cityId
=
json
[
'city_id'
];
birth
=
json
[
'birth'
];
countryId
=
json
[
'country_id'
];
logined
=
json
[
'logined'
];
detailSetted
=
json
[
'detail_setted'
];
tagSetted
=
json
[
'tag_setted'
];
questionUrl
=
json
[
'question_url'
];
isBind
=
json
[
'is_bind'
];
countryInfoName
=
json
[
'country_info_name'
];
countryInfoId
=
json
[
'country_info_id'
];
countryInfoLanguage
=
json
[
'country_info_language'
];
insBindId
=
json
[
'ins_bind_id'
];
registerTime
=
json
[
'register_time'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'user_id'
]
=
this
.
userId
;
data
[
'nick_name'
]
=
this
.
nickName
;
data
[
'profile_pic'
]
=
this
.
profilePic
;
data
[
'has_answered'
]
=
this
.
hasAnswered
;
data
[
'has_scan_face'
]
=
this
.
hasScanFace
;
data
[
'id'
]
=
this
.
id
;
data
[
'gender'
]
=
this
.
gender
;
data
[
'city_id'
]
=
this
.
cityId
;
data
[
'birth'
]
=
this
.
birth
;
data
[
'country_id'
]
=
this
.
countryId
;
data
[
'logined'
]
=
this
.
logined
;
data
[
'detail_setted'
]
=
this
.
detailSetted
;
data
[
'tag_setted'
]
=
this
.
tagSetted
;
data
[
'question_url'
]
=
this
.
questionUrl
;
data
[
'is_bind'
]
=
this
.
isBind
;
data
[
'country_info_name'
]
=
this
.
countryInfoName
;
data
[
'country_info_id'
]
=
this
.
countryInfoId
;
data
[
'country_info_language'
]
=
this
.
countryInfoLanguage
;
data
[
'ins_bind_id'
]
=
this
.
insBindId
;
data
[
'register_time'
]
=
this
.
registerTime
;
return
data
;
}
String
ins_bind_id
;
String
register_time
;
}
lib/userModel/service/remote/entity/UserEntity.user.dart
0 → 100644
View file @
2c0efeea
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// UserGenerator
// **************************************************************************
import
'package:rxdart/rxdart.dart'
;
import
'package:gmalpha_flutter/commonModel/app_module.dart'
;
class
UserEntityImpl
{
factory
UserEntityImpl
()
=>
_sharedInstance
();
static
UserEntityImpl
_instance
;
UserEntityImpl
.
_
()
{}
static
UserEntityImpl
_sharedInstance
()
{
if
(
_instance
==
null
)
{
_instance
=
UserEntityImpl
.
_
();
}
return
_instance
;
}
String
_userId
;
Observable
<
bool
>
saveuserId
(
String
userId
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"user_uid"
,
userId
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_userId
=
userId
;
}
return
value
;
});
}
Observable
<
String
>
getuserId
()
{
if
(
_userId
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_userId
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"user_uid"
));
}
String
_nickName
;
Observable
<
bool
>
savenickName
(
String
nickName
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"username"
,
nickName
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_nickName
=
nickName
;
}
return
value
;
});
}
Observable
<
String
>
getnickName
()
{
if
(
_nickName
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_nickName
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"username"
));
}
String
_profilePic
;
Observable
<
bool
>
saveprofilePic
(
String
profilePic
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"potrait"
,
profilePic
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_profilePic
=
profilePic
;
}
return
value
;
});
}
Observable
<
String
>
getprofilePic
()
{
if
(
_profilePic
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_profilePic
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"potrait"
));
}
bool
_hasAnswered
;
Observable
<
bool
>
savehasAnswered
(
bool
hasAnswered
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveBoolKv
(
"personal_qa"
,
hasAnswered
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_hasAnswered
=
hasAnswered
;
}
return
value
;
});
}
Observable
<
bool
>
gethasAnswered
()
{
if
(
_hasAnswered
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_hasAnswered
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getBoolKv
(
"personal_qa"
));
}
bool
_hasScanFace
;
Observable
<
bool
>
savehasScanFace
(
bool
hasScanFace
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveBoolKv
(
"has_scan_face"
,
hasScanFace
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_hasScanFace
=
hasScanFace
;
}
return
value
;
});
}
Observable
<
bool
>
gethasScanFace
()
{
if
(
_hasScanFace
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_hasScanFace
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getBoolKv
(
"has_scan_face"
));
}
String
_gender
;
Observable
<
bool
>
savegender
(
String
gender
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"gender"
,
gender
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_gender
=
gender
;
}
return
value
;
});
}
Observable
<
String
>
getgender
()
{
if
(
_gender
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_gender
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"gender"
));
}
String
_cityId
;
Observable
<
bool
>
savecityId
(
String
cityId
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"current_city_id"
,
cityId
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_cityId
=
cityId
;
}
return
value
;
});
}
Observable
<
String
>
getcityId
()
{
if
(
_cityId
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_cityId
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"current_city_id"
));
}
int
_birth
;
Observable
<
bool
>
savebirth
(
int
birth
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveIntKv
(
"birthday"
,
birth
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_birth
=
birth
;
}
return
value
;
});
}
Observable
<
int
>
getbirth
()
{
if
(
_birth
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_birth
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getIntKv
(
"birthday"
));
}
String
_countryId
;
Observable
<
bool
>
savecountryId
(
String
countryId
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"country_id"
,
countryId
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_countryId
=
countryId
;
}
return
value
;
});
}
Observable
<
String
>
getcountryId
()
{
if
(
_countryId
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_countryId
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"country_id"
));
}
bool
_detailSetted
;
Observable
<
bool
>
savedetailSetted
(
bool
detailSetted
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveBoolKv
(
"detail_setted"
,
detailSetted
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_detailSetted
=
detailSetted
;
}
return
value
;
});
}
Observable
<
bool
>
getdetailSetted
()
{
if
(
_detailSetted
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_detailSetted
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getBoolKv
(
"detail_setted"
));
}
String
_questionUrl
;
Observable
<
bool
>
savequestionUrl
(
String
questionUrl
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"question_url"
,
questionUrl
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_questionUrl
=
questionUrl
;
}
return
value
;
});
}
Observable
<
String
>
getquestionUrl
()
{
if
(
_questionUrl
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_questionUrl
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"question_url"
));
}
bool
_isBind
;
Observable
<
bool
>
saveisBind
(
bool
isBind
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveBoolKv
(
"user_bind_mobile"
,
isBind
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_isBind
=
isBind
;
}
return
value
;
});
}
Observable
<
bool
>
getisBind
()
{
if
(
_isBind
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_isBind
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getBoolKv
(
"user_bind_mobile"
));
}
String
_countryInfoName
;
Observable
<
bool
>
savecountryInfoName
(
String
countryInfoName
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"country_name"
,
countryInfoName
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_countryInfoName
=
countryInfoName
;
}
return
value
;
});
}
Observable
<
String
>
getcountryInfoName
()
{
if
(
_countryInfoName
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_countryInfoName
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"country_name"
));
}
String
_countryInfoId
;
Observable
<
bool
>
savecountryInfoId
(
String
countryInfoId
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"country_id"
,
countryInfoId
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_countryInfoId
=
countryInfoId
;
}
return
value
;
});
}
Observable
<
String
>
getcountryInfoId
()
{
if
(
_countryInfoId
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_countryInfoId
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"country_id"
));
}
String
_countryInfoLanguage
;
Observable
<
bool
>
savecountryInfoLanguage
(
String
countryInfoLanguage
)
{
return
Observable
.
fromFuture
(
mmKvUtil
.
saveStringKv
(
"country_language"
,
countryInfoLanguage
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_countryInfoLanguage
=
countryInfoLanguage
;
}
return
value
;
});
}
Observable
<
String
>
getcountryInfoLanguage
()
{
if
(
_countryInfoLanguage
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_countryInfoLanguage
));
}
return
Observable
.
fromFuture
(
mmKvUtil
.
getStringKv
(
"country_language"
));
}
}
lib/userModel/user/UserUtil.user.dart
deleted
100644 → 0
View file @
29e28e7c
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// UserGenerator
// **************************************************************************
import
'package:rxdart/rxdart.dart'
;
import
'package:gmalpha_flutter/commonModel/app_module.dart'
;
class
UserCenterImpl
{
factory
UserCenterImpl
()
=>
_sharedInstance
();
static
UserCenterImpl
_instance
;
UserCenterImpl
.
_
()
{}
static
UserCenterImpl
_sharedInstance
()
{
if
(
_instance
==
null
)
{
_instance
=
UserCenterImpl
.
_
();
}
return
_instance
;
}
String
_User_id
;
Observable
<
bool
>
saveUser_id
(
String
User_id
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"user_uid"
,
User_id
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_User_id
=
User_id
;
}
return
value
;
});
}
Observable
<
String
>
getUser_id
()
{
if
(
_User_id
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_User_id
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"user_uid"
));
}
String
_nick_name
;
Observable
<
bool
>
savenick_name
(
String
nick_name
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"username"
,
nick_name
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_nick_name
=
nick_name
;
}
return
value
;
});
}
Observable
<
String
>
getnick_name
()
{
if
(
_nick_name
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_nick_name
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"username"
));
}
String
_profile_pic
;
Observable
<
bool
>
saveprofile_pic
(
String
profile_pic
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"potrait"
,
profile_pic
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_profile_pic
=
profile_pic
;
}
return
value
;
});
}
Observable
<
String
>
getprofile_pic
()
{
if
(
_profile_pic
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_profile_pic
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"potrait"
));
}
bool
_has_answered
;
Observable
<
bool
>
savehas_answered
(
bool
has_answered
)
{
return
Observable
.
fromFuture
(
saveBoolKv
(
"personal_qa"
,
has_answered
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_has_answered
=
has_answered
;
}
return
value
;
});
}
Observable
<
bool
>
gethas_answered
()
{
if
(
_has_answered
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_has_answered
));
}
return
Observable
.
fromFuture
(
getBoolKv
(
"personal_qa"
));
}
bool
_has_scan_face
;
Observable
<
bool
>
savehas_scan_face
(
bool
has_scan_face
)
{
return
Observable
.
fromFuture
(
saveBoolKv
(
"has_scan_face"
,
has_scan_face
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_has_scan_face
=
has_scan_face
;
}
return
value
;
});
}
Observable
<
bool
>
gethas_scan_face
()
{
if
(
_has_scan_face
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_has_scan_face
));
}
return
Observable
.
fromFuture
(
getBoolKv
(
"has_scan_face"
));
}
String
_gender
;
Observable
<
bool
>
savegender
(
String
gender
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"gender"
,
gender
)).
map
((
value
)
{
if
(
value
)
{
this
.
_gender
=
gender
;
}
return
value
;
});
}
Observable
<
String
>
getgender
()
{
if
(
_gender
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_gender
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"gender"
));
}
String
_city_id
;
Observable
<
bool
>
savecity_id
(
String
city_id
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"current_city_id"
,
city_id
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_city_id
=
city_id
;
}
return
value
;
});
}
Observable
<
String
>
getcity_id
()
{
if
(
_city_id
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_city_id
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"current_city_id"
));
}
int
_birth
;
Observable
<
bool
>
savebirth
(
int
birth
)
{
return
Observable
.
fromFuture
(
saveIntKv
(
"birthday"
,
birth
)).
map
((
value
)
{
if
(
value
)
{
this
.
_birth
=
birth
;
}
return
value
;
});
}
Observable
<
int
>
getbirth
()
{
if
(
_birth
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_birth
));
}
return
Observable
.
fromFuture
(
getIntKv
(
"birthday"
));
}
String
_country_id
;
Observable
<
bool
>
savecountry_id
(
String
country_id
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"country_id"
,
country_id
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_country_id
=
country_id
;
}
return
value
;
});
}
Observable
<
String
>
getcountry_id
()
{
if
(
_country_id
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_country_id
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"country_id"
));
}
bool
_detail_setted
;
Observable
<
bool
>
savedetail_setted
(
bool
detail_setted
)
{
return
Observable
.
fromFuture
(
saveBoolKv
(
"detail_setted"
,
detail_setted
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_detail_setted
=
detail_setted
;
}
return
value
;
});
}
Observable
<
bool
>
getdetail_setted
()
{
if
(
_detail_setted
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_detail_setted
));
}
return
Observable
.
fromFuture
(
getBoolKv
(
"detail_setted"
));
}
String
_question_url
;
Observable
<
bool
>
savequestion_url
(
String
question_url
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"question_url"
,
question_url
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_question_url
=
question_url
;
}
return
value
;
});
}
Observable
<
String
>
getquestion_url
()
{
if
(
_question_url
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_question_url
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"question_url"
));
}
bool
_is_bind
;
Observable
<
bool
>
saveis_bind
(
bool
is_bind
)
{
return
Observable
.
fromFuture
(
saveBoolKv
(
"user_bind_mobile"
,
is_bind
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_is_bind
=
is_bind
;
}
return
value
;
});
}
Observable
<
bool
>
getis_bind
()
{
if
(
_is_bind
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_is_bind
));
}
return
Observable
.
fromFuture
(
getBoolKv
(
"user_bind_mobile"
));
}
String
_country_info_name
;
Observable
<
bool
>
savecountry_info_name
(
String
country_info_name
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"country_name"
,
country_info_name
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_country_info_name
=
country_info_name
;
}
return
value
;
});
}
Observable
<
String
>
getcountry_info_name
()
{
if
(
_country_info_name
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_country_info_name
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"country_name"
));
}
String
_country_info_id
;
Observable
<
bool
>
savecountry_info_id
(
String
country_info_id
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"country_id"
,
country_info_id
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_country_info_id
=
country_info_id
;
}
return
value
;
});
}
Observable
<
String
>
getcountry_info_id
()
{
if
(
_country_info_id
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_country_info_id
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"country_id"
));
}
String
_country_info_language
;
Observable
<
bool
>
savecountry_info_language
(
String
country_info_language
)
{
return
Observable
.
fromFuture
(
saveStringKv
(
"country_language"
,
country_info_language
))
.
map
((
value
)
{
if
(
value
)
{
this
.
_country_info_language
=
country_info_language
;
}
return
value
;
});
}
Observable
<
String
>
getcountry_info_language
()
{
if
(
_country_info_language
!=
null
)
{
return
Observable
.
fromFuture
(
Future
.
value
(
_country_info_language
));
}
return
Observable
.
fromFuture
(
getStringKv
(
"country_language"
));
}
}
pubspec.lock
View file @
2c0efeea
...
...
@@ -58,7 +58,7 @@ packages:
source: hosted
version: "1.0.5"
build_runner:
dependency: "direct
main
"
dependency: "direct
dev
"
description:
name: build_runner
url: "https://pub.flutter-io.cn"
...
...
@@ -250,14 +250,7 @@ packages:
name: json_annotation
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.4.0"
json_serializable:
dependency: "direct main"
description:
name: json_serializable
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
version: "2.3.0"
kernel:
dependency: transitive
description:
...
...
@@ -294,7 +287,7 @@ packages:
source: hosted
version: "0.9.6+3"
mmkv_flutter:
dependency: "direct
dev
"
dependency: "direct
main
"
description:
name: mmkv_flutter
url: "https://pub.flutter-io.cn"
...
...
@@ -370,13 +363,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.22.0"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
shelf:
dependency: transitive
description:
...
...
pubspec.yaml
View file @
2c0efeea
...
...
@@ -28,18 +28,19 @@ dependencies:
cupertino_icons
:
^0.1.2
dio
:
^2.1.0
rxdart
:
^0.22.0
#链式编程
json_serializable
:
^3.0.0
#json to model
build_runner
:
^1.6.1
# json_serializable: ^3.0.0 #json to model
pull_to_refresh
:
^1.5.0
shared_preferences
:
^0.4.3
#
shared_preferences: ^0.4.3
# flutter_easyrefresh: ^1.2.7 # 上拉下拉刷新组件
mmkv_flutter
:
^1.0.10
dev_dependencies
:
source_gen
:
'
>=0.8.0'
build_runner
:
^1.6.1
mmkv_flutter
:
flutter_test
:
sdk
:
flutter
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment