Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
netrain_flutter_app
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
邹志胜
netrain_flutter_app
Commits
38e9efb9
Commit
38e9efb9
authored
Jul 20, 2021
by
jishuaishuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVVM的ViewModel拿到接口了,等待解析
parent
1aac69f7
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
161 additions
and
28 deletions
+161
-28
ModelDemo.dart
netrain_flutter_app/lib/jishuaishuai/MVVMDemo/ModelDemo.dart
+17
-0
ViewDemo.dart
netrain_flutter_app/lib/jishuaishuai/MVVMDemo/ViewDemo.dart
+41
-0
ViewModelDemo.dart
..._flutter_app/lib/jishuaishuai/MVVMDemo/ViewModelDemo.dart
+15
-0
fifthVC.dart
netrain_flutter_app/lib/jishuaishuai/fifthVC.dart
+12
-4
firstVC.dart
netrain_flutter_app/lib/jishuaishuai/firstVC.dart
+11
-0
fourthVC.dart
netrain_flutter_app/lib/jishuaishuai/fourthVC.dart
+4
-1
secondVC.dart
netrain_flutter_app/lib/jishuaishuai/secondVC.dart
+23
-1
main.dart
netrain_flutter_app/lib/main.dart
+38
-22
No files found.
netrain_flutter_app/lib/jishuaishuai/MVVMDemo/ModelDemo.dart
0 → 100644
View file @
38e9efb9
import
'package:dio/dio.dart'
;
class
ApiPostSomeUrl
{
/**
* 登录方法
* id 参数
*/
dynamic
get
(
String
curNum
)
async
{
return
await
Dio
().
get
(
"http://swyy.cying.com.cn/common/preheat"
,
queryParameters:
{
"curNum"
:
curNum
,
},
);
}
}
\ No newline at end of file
netrain_flutter_app/lib/jishuaishuai/MVVMDemo/ViewDemo.dart
0 → 100644
View file @
38e9efb9
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/jishuaishuai/MVVMDemo/ViewModelDemo.dart'
;
import
'package:provider/provider.dart'
;
class
MVVMViewDemo
extends
StatefulWidget
{
MVVMViewDemo
({
Key
key
})
:
super
(
key:
key
);
@override
_MVVMViewDemoState
createState
()
{
return
_MVVMViewDemoState
();
}
}
class
_MVVMViewDemoState
extends
State
<
MVVMViewDemo
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"MVVM模式"
),
),
body:
ElevatedButton
(
child:
Text
(
"点击调用get请求"
),
onPressed:
()
async
{
context
.
read
<
ViewModelGet
>().
get
(
"1"
);
},
),
);
}
}
\ No newline at end of file
netrain_flutter_app/lib/jishuaishuai/MVVMDemo/ViewModelDemo.dart
0 → 100644
View file @
38e9efb9
import
'ModelDemo.dart'
;
import
'package:flutter/material.dart'
;
import
'dart:convert'
as
JSON
;
class
ViewModelGet
extends
ChangeNotifier
{
ApiPostSomeUrl
_model
=
ApiPostSomeUrl
();
void
get
(
String
curNum
)
async
{
var
result
=
await
_model
.
get
(
curNum
);
print
(
result
);
// Map<,Object>map =JSON.jsonDecode(result);
List
list
=
JSON
.
jsonDecode
(
result
);
print
(
list
);
}
}
\ No newline at end of file
netrain_flutter_app/lib/jishuaishuai/fifthVC.dart
View file @
38e9efb9
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/jishuaishuai/MVVMDemo/ViewDemo.dart'
;
class
fifthDemo
extends
StatefulWidget
{
class
fifthDemo
extends
StatefulWidget
{
fifthDemo
({
Key
key
})
:
super
(
key:
key
);
//
fifthDemo({Key key}) : super(key: key);
@override
@override
_fifthDemoState
createState
()
{
_fifthDemoState
createState
()
{
...
@@ -35,7 +36,7 @@ class _fifthDemoState extends State<fifthDemo> {
...
@@ -35,7 +36,7 @@ class _fifthDemoState extends State<fifthDemo> {
}
}
class
fifthListViewDemo
extends
StatefulWidget
{
class
fifthListViewDemo
extends
StatefulWidget
{
fifthListViewDemo
({
Key
key
})
:
super
(
key:
key
);
//
fifthListViewDemo({Key key}) : super(key: key);
@override
@override
_fifthListViewDemoState
createState
()
{
_fifthListViewDemoState
createState
()
{
...
@@ -71,11 +72,16 @@ class _fifthListViewDemoState extends State<fifthListViewDemo> {
...
@@ -71,11 +72,16 @@ class _fifthListViewDemoState extends State<fifthListViewDemo> {
}
}
return
Container
(
return
Container
(
child:
Flex
(
child:
Flex
(
direction:
Axis
.
vertical
,
children:
[
children:
[
Text
(
listArr
[
index
].
toString
()),
Text
(
listArr
[
index
].
toString
()),
ElevatedButton
(
onPressed:
(){
ElevatedButton
(
onPressed:
(){
print
(
"点击了"
);
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
},
child:
Text
(
"我是个按钮"
)
),
builder:
(
context
){
return
MVVMViewDemo
();
}
));
},
child:
Text
(
"点击进入MVVM设计模式页面"
)
),
Container
(
Container
(
width:
100
,
width:
100
,
height:
300
,
height:
300
,
...
@@ -86,10 +92,12 @@ class _fifthListViewDemoState extends State<fifthListViewDemo> {
...
@@ -86,10 +92,12 @@ class _fifthListViewDemoState extends State<fifthListViewDemo> {
),
),
);
);
}),
}),
onRefresh:
_onRefresh
,
),
),
);
);
}
}
Future
_onRefresh
()
async
{
Future
_onRefresh
()
async
{
await
Future
.
delayed
(
await
Future
.
delayed
(
Duration
(
seconds:
2
),
Duration
(
seconds:
2
),
...
...
netrain_flutter_app/lib/jishuaishuai/firstVC.dart
View file @
38e9efb9
import
'package:dio/dio.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/common/Images.dart'
;
import
'package:netrain_flutter_app/common/Images.dart'
;
import
'secondVC.dart'
;
import
'secondVC.dart'
;
...
@@ -141,6 +142,9 @@ class imageiconDemo extends StatelessWidget {
...
@@ -141,6 +142,9 @@ class imageiconDemo extends StatelessWidget {
// fit: BoxFit.fitWidth
// fit: BoxFit.fitWidth
// ),
// ),
Image
.
asset
(
Images
.
ic_my_info
),
Image
.
asset
(
Images
.
ic_my_info
),
ElevatedButton
(
onPressed:
(){
apiGet
();
},
child:
Text
(
"测试点击事件请求"
))
],
],
);
);
...
@@ -150,3 +154,10 @@ class imageiconDemo extends StatelessWidget {
...
@@ -150,3 +154,10 @@ class imageiconDemo extends StatelessWidget {
}
}
}
}
class
apiGet
{
var
result
=
Dio
().
get
(
"http://api.td0f7/cn:8083/dio/dio/test?id=1"
);
}
\ No newline at end of file
netrain_flutter_app/lib/jishuaishuai/fourthVC.dart
View file @
38e9efb9
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/jishuaishuai/fifthVC.dart'
;
class
fourthDemo
extends
StatefulWidget
{
class
fourthDemo
extends
StatefulWidget
{
fourthDemo
({
Key
key
})
:
super
(
key:
key
);
fourthDemo
({
Key
key
})
:
super
(
key:
key
);
...
@@ -74,7 +75,9 @@ class _someDemoState extends State<someDemo> {
...
@@ -74,7 +75,9 @@ class _someDemoState extends State<someDemo> {
Text
(
e
.
toString
()),
Text
(
e
.
toString
()),
ElevatedButton
(
ElevatedButton
(
onPressed:
()
{
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
){
return
fifthDemo
();
}));
},
},
child:
Text
(
"点击进入第5个页面"
))
child:
Text
(
"点击进入第5个页面"
))
],
],
...
...
netrain_flutter_app/lib/jishuaishuai/secondVC.dart
View file @
38e9efb9
...
@@ -17,7 +17,7 @@ class twoVCdemo extends StatelessWidget {
...
@@ -17,7 +17,7 @@ class twoVCdemo extends StatelessWidget {
body:
Column
(
body:
Column
(
children:
[
children:
[
ElevatedButton
(
ElevatedButton
(
child:
Text
(
"
第二页面的按钮,跳转带参数过去
"
),
child:
Text
(
"
传参数进入第三个页面
"
),
onPressed:
()
{
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
)
{
builder:
(
context
)
{
...
@@ -41,6 +41,28 @@ class twoVCdemo extends StatelessWidget {
...
@@ -41,6 +41,28 @@ class twoVCdemo extends StatelessWidget {
direction:
Axis
.
horizontal
,
direction:
Axis
.
horizontal
,
children:
[
children:
[
Image
.
asset
(
Images
.
ic_home_normal
,
alignment:
Alignment
.
center
,),
Image
.
asset
(
Images
.
ic_home_normal
,
alignment:
Alignment
.
center
,),
Align
(
alignment:
Alignment
(-
0.5
,
0.5
),
child:
Stack
(
alignment:
AlignmentDirectional
.
center
,
children:
[
Container
(
width:
100
,
height:
30
,
color:
Colors
.
orange
,
),
Container
(
color:
Colors
.
red
,
child:
Text
(
"点击进入"
),
),
Positioned
(
right:
0
,
top:
5
,
child:
Image
.
asset
(
Images
.
ic_home_normal
)),
],
),
)
],
],
)
)
...
...
netrain_flutter_app/lib/main.dart
View file @
38e9efb9
import
'package:flustars/flustars.dart'
;
import
'package:flustars/flustars.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_localizations/flutter_localizations.dart'
;
import
'package:flutter_localizations/flutter_localizations.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:netrain_flutter_app/jishuaishuai/MVVMDemo/ViewDemo.dart'
;
import
'package:netrain_flutter_app/jishuaishuai/MVVMDemo/ViewModelDemo.dart'
;
import
'package:netrain_flutter_app/xuehao/BottomNavpage.dart'
;
import
'package:netrain_flutter_app/xuehao/BottomNavpage.dart'
;
import
'package:netrain_flutter_app/xuehao/car_details.dart'
;
import
'package:netrain_flutter_app/xuehao/car_details.dart'
;
import
'package:netrain_flutter_app/common/AppColors.dart'
;
import
'package:netrain_flutter_app/common/AppColors.dart'
;
import
'package:netrain_flutter_app/xuehao/grid_page.dart'
;
import
'package:netrain_flutter_app/xuehao/grid_page.dart'
;
import
'package:netrain_flutter_app/xuehao/list_page.dart'
;
import
'package:netrain_flutter_app/xuehao/list_page.dart'
;
import
'package:provider/provider.dart'
;
import
'laishanqi/Stateful_page.dart'
;
import
'laishanqi/Stateful_page.dart'
;
import
'laishanqi/Stateless_page.dart'
;
import
'laishanqi/Stateless_page.dart'
;
...
@@ -27,12 +31,23 @@ import 'zhangfeng/LayoutDemo.dart';
...
@@ -27,12 +31,23 @@ import 'zhangfeng/LayoutDemo.dart';
import
'jishuaishuai/firstVC.dart'
;
import
'jishuaishuai/firstVC.dart'
;
void
main
(
)
{
void
main
(
)
{
runApp
(
MyApp
());
runApp
(
MultiProvider
(
providers:
[
ChangeNotifierProvider
(
create:
(
context
)
=>
ViewModelGet
(),
)
],
child:
MyApp
(),
)
);
// runApp(Login());
// runApp(Login());
// runApp(TestPage());
// runApp(TestPage());
UserModel
.
getModel
();
UserModel
.
getModel
();
print
(
"启动"
);
print
(
"启动"
);
}
}
class
MyApp
extends
StatelessWidget
{
class
MyApp
extends
StatelessWidget
{
...
@@ -78,7 +93,7 @@ class MyApp extends StatelessWidget {
...
@@ -78,7 +93,7 @@ class MyApp extends StatelessWidget {
"LoginRequestPage"
:
(
context
)
=>
LoginRequestPage
(),
"LoginRequestPage"
:
(
context
)
=>
LoginRequestPage
(),
"PageView"
:
(
context
)
=>
SampleAppPage
(),
"PageView"
:
(
context
)
=>
SampleAppPage
(),
"LayoutDemo"
:
(
context
)
=>
LayoutDemo
(),
"LayoutDemo"
:
(
context
)
=>
LayoutDemo
(),
"main"
:
(
context
)
=>
mainPage
(),
"main"
:
(
context
)
=>
mainPage
(
context
),
"firstVC"
:
(
context
)
=>
jssPageDemo
(),
"firstVC"
:
(
context
)
=>
jssPageDemo
(),
"car_details"
:
(
context
)
=>
CarDetailsPage
(),
"car_details"
:
(
context
)
=>
CarDetailsPage
(),
"student"
:
(
context
)
=>
jssPageDemo
(),
"student"
:
(
context
)
=>
jssPageDemo
(),
...
@@ -95,7 +110,7 @@ class MyApp extends StatelessWidget {
...
@@ -95,7 +110,7 @@ class MyApp extends StatelessWidget {
}
}
}
}
Widget
mainPage
(
)
{
Widget
mainPage
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
title:
Text
(
"NetRain Flutter学习计划"
),
title:
Text
(
"NetRain Flutter学习计划"
),
...
@@ -119,7 +134,7 @@ class _RouterNavigatorState extends State<RouterNavigator> {
...
@@ -119,7 +134,7 @@ class _RouterNavigatorState extends State<RouterNavigator> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Container
(
return
Container
(
child:
Container
(
child:
Container
(
margin:
EdgeInsets
.
only
(
left:
10
,
right:
10
),
margin:
EdgeInsets
.
only
(
left:
10
,
right:
10
),
child:
Wrap
(
child:
Wrap
(
spacing:
10
,
spacing:
10
,
children:
[
children:
[
...
@@ -131,31 +146,32 @@ class _RouterNavigatorState extends State<RouterNavigator> {
...
@@ -131,31 +146,32 @@ class _RouterNavigatorState extends State<RouterNavigator> {
byName
=
value
;
byName
=
value
;
});
});
}),
}),
_item
(
"登陆"
,
LoginPage
(),
'login'
),
_item
(
"登陆"
,
LoginPage
(),
'login'
,
context
),
_item
(
"首页"
,
LessGroupPage
(),
'doctor_MainPage'
),
_item
(
"首页"
,
LessGroupPage
(),
'doctor_MainPage'
,
context
),
_item
(
"less页面"
,
LessGroupPage
(),
'less'
),
_item
(
"less页面"
,
LessGroupPage
(),
'less'
,
context
),
_item
(
"ful页面"
,
FulGroupPage
(),
'ful'
),
_item
(
"ful页面"
,
FulGroupPage
(),
'ful'
,
context
),
_item
(
"layout页面"
,
LayoutPage
(),
'layout'
),
_item
(
"layout页面"
,
LayoutPage
(),
'layout'
,
context
),
_item
(
"拍照页面"
,
PhotoApp
(),
'photo'
),
_item
(
"拍照页面"
,
PhotoApp
(),
'photo'
,
context
),
_item
(
"登录网络请求"
,
LoginRequestPage
(),
'LoginRequestPage'
),
_item
(
"登录网络请求"
,
LoginRequestPage
(),
'LoginRequestPage'
,
context
),
_item
(
"CustomTabPage"
,
TabBarPage
(),
'CustomTabPage'
),
_item
(
"CustomTabPage"
,
TabBarPage
(),
'CustomTabPage'
,
context
),
_item
(
"PageView"
,
SampleAppPage
(),
'PageView'
),
_item
(
"PageView"
,
SampleAppPage
(),
'PageView'
,
context
),
_item
(
"LayoutDemo"
,
LayoutDemo
(),
'LayoutDemo'
),
_item
(
"LayoutDemo"
,
LayoutDemo
(),
'LayoutDemo'
,
context
),
_item
(
"listview页面"
,
List_Page
(),
'listPage'
),
_item
(
"listview页面"
,
List_Page
(),
'listPage'
,
context
),
_item
(
"jssDemo"
,
jssPageDemo
(),
'firstVC'
),
_item
(
"jssDemo"
,
jssPageDemo
(),
'firstVC'
,
context
),
_item
(
"jssDemo"
,
jssPageDemo
(),
'student'
),
_item
(
"jssDemo"
,
jssPageDemo
(),
'student'
,
context
),
_item
(
"gridView"
,
GridPage
(),
'grid_page'
),
_item
(
"gridView"
,
GridPage
(),
'grid_page'
,
context
),
_item
(
"BottomNav"
,
BottomNavPage
(),
'bottom_page'
),
_item
(
"BottomNav"
,
BottomNavPage
(),
'bottom_page'
,
context
),
],
],
),
),
),
),
);
);
}
}
_item
(
String
title
,
page
,
String
routeName
)
{
_item
(
String
title
,
page
,
String
routeName
,
BuildContext
context
)
{
return
Container
(
return
Container
(
child:
ElevatedButton
(
child:
ElevatedButton
(
onPressed:
()
{
onPressed:
()
{
// Navigator.of(context).push(route)
if
(
byName
)
{
if
(
byName
)
{
Navigator
.
pushNamed
(
context
,
routeName
);
Navigator
.
pushNamed
(
context
,
routeName
);
}
else
{
}
else
{
...
...
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