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
2a777710
Commit
2a777710
authored
Jul 14, 2021
by
jishuaishuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listview练习 刷新练习
parent
e185390e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
359 additions
and
23 deletions
+359
-23
fifthVC.dart
netrain_flutter_app/lib/jishuaishuai/fifthVC.dart
+102
-0
firstVC.dart
netrain_flutter_app/lib/jishuaishuai/firstVC.dart
+6
-0
fourthVC.dart
netrain_flutter_app/lib/jishuaishuai/fourthVC.dart
+103
-0
secondVC.dart
netrain_flutter_app/lib/jishuaishuai/secondVC.dart
+11
-11
thirdVC.dart
netrain_flutter_app/lib/jishuaishuai/thirdVC.dart
+137
-12
No files found.
netrain_flutter_app/lib/jishuaishuai/fifthVC.dart
0 → 100644
View file @
2a777710
import
'package:flutter/material.dart'
;
class
fifthDemo
extends
StatefulWidget
{
fifthDemo
({
Key
key
})
:
super
(
key:
key
);
@override
_fifthDemoState
createState
()
{
return
_fifthDemoState
();
}
}
class
_fifthDemoState
extends
State
<
fifthDemo
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"第五个页面"
),
),
body:
fifthListViewDemo
(),
);
}
}
class
fifthListViewDemo
extends
StatefulWidget
{
fifthListViewDemo
({
Key
key
})
:
super
(
key:
key
);
@override
_fifthListViewDemoState
createState
()
{
return
_fifthListViewDemoState
();
}
}
class
_fifthListViewDemoState
extends
State
<
fifthListViewDemo
>
{
List
<
int
>
listArr
=
List
();
@override
void
initState
()
{
super
.
initState
();
for
(
var
i
=
0
;
i
<
100
;
i
++){
listArr
.
add
(
i
);
}
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
return
Scrollbar
(
child:
RefreshIndicator
(
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
if
(
index
==
2
)
{
}
return
Container
(
child:
Flex
(
children:
[
Text
(
listArr
[
index
].
toString
()),
ElevatedButton
(
onPressed:
(){
print
(
"点击了"
);
},
child:
Text
(
"我是个按钮"
)
),
Container
(
width:
100
,
height:
300
,
color:
Colors
.
orange
,
)
],
),
);
}),
),
);
}
Future
_onRefresh
()
async
{
await
Future
.
delayed
(
Duration
(
seconds:
2
),
()
{
print
(
"object"
);
},
);
return
""
;
}
}
\ No newline at end of file
netrain_flutter_app/lib/jishuaishuai/firstVC.dart
View file @
2a777710
...
...
@@ -3,6 +3,8 @@ import 'package:netrain_flutter_app/common/Images.dart';
import
'secondVC.dart'
;
class
jssPageDemo
extends
StatelessWidget
{
// const ({Key? key}) : super(key: key)
...
...
@@ -91,14 +93,17 @@ class buttonDemo extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
return
Column
(
children:
[
//改用ElevatedButton
RaisedButton
(
onPressed:
(){},
child:
Text
(
"漂浮按钮"
)
),
//改用 TextButton
FlatButton
(
onPressed:
(){},
child:
Text
(
"扁平按钮"
)
),
//改用 TextButton
FlatButton
.
icon
(
onPressed:
(){},
icon:
Icon
(
Icons
.
outbound
),
...
...
@@ -106,6 +111,7 @@ class buttonDemo extends StatelessWidget {
color:
Colors
.
black
,
textColor:
Colors
.
white
,
),
//改用 OutlinedButton
OutlineButton
(
onPressed:
(){},
child:
Text
(
"边框按钮"
),
),
...
...
netrain_flutter_app/lib/jishuaishuai/fourthVC.dart
0 → 100644
View file @
2a777710
import
'package:flutter/material.dart'
;
class
fourthDemo
extends
StatefulWidget
{
fourthDemo
({
Key
key
})
:
super
(
key:
key
);
@override
_fourthDemoState
createState
()
{
return
_fourthDemoState
();
}
}
class
_fourthDemoState
extends
State
<
fourthDemo
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"jss测试第四个页面"
),
),
body:
someDemo
());
}
}
class
someDemo
extends
StatefulWidget
{
someDemo
({
Key
key
})
:
super
(
key:
key
);
@override
_someDemoState
createState
()
{
return
_someDemoState
();
}
}
class
_someDemoState
extends
State
<
someDemo
>
{
List
<
int
>
listArrData
=
List
();
@override
void
initState
()
{
super
.
initState
();
for
(
var
i
=
0
;
i
<
100
;
i
++)
{
listArrData
.
add
(
i
);
}
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
return
Scrollbar
(
child:
RefreshIndicator
(
child:
ListView
(
//y轴
scrollDirection:
Axis
.
vertical
,
children:
listArrData
.
map
((
e
)
=>
Container
(
width:
200
,
height:
100
,
child:
Flex
(
direction:
Axis
.
vertical
,
children:
[
Text
(
e
.
toString
()),
ElevatedButton
(
onPressed:
()
{
},
child:
Text
(
"点击进入第5个页面"
))
],
),
decoration:
BoxDecoration
(
color:
Colors
.
red
,
),
//旋转跳跃我闭着眼
// transform: Matrix4.rotationZ(0.5),
))
.
toList
(),
),
onRefresh:
_onRefresh
,
));
}
Future
_onRefresh
()
async
{
await
Future
.
delayed
(
Duration
(
seconds:
2
),
()
{
print
(
"object"
);
},
);
return
""
;
}
}
netrain_flutter_app/lib/jishuaishuai/secondVC.dart
View file @
2a777710
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/common/Images.dart'
;
import
'thirdVC.dart'
;
class
twoVCdemo
extends
StatelessWidget
{
// const ({Key? key}) : super(key: key);
...
...
@@ -12,20 +11,21 @@ class twoVCdemo extends StatelessWidget {
appBar:
AppBar
(
title:
Text
(
"jssDemo第二个页面的标题"
),
),
body:
Column
(
children:
[
ElevatedButton
(
child:
Text
(
"第二页面的按钮,跳转带参数过去"
),
onPressed:
()
{
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
){
builder:
(
context
)
{
return
nextViewDemo
();
},
settings:
RouteSettings
(
name:
"我是传过去的"
,
arguments:
"参数,是对象类型"
,
arguments:
"参数,是对象类型"
,
),
//是否有返回
maintainState:
false
,
...
...
@@ -35,12 +35,12 @@ class twoVCdemo extends StatelessWidget {
);
},
),
Flex
(
direction:
Axis
.
horizontal
,
children:
[
Image
.
asset
(
Images
.
ic_home_normal
,
alignment:
Alignment
.
center
,),
Flex
(
direction:
Axis
.
horizontal
,
children:
[
Image
.
asset
(
Images
.
ic_home_normal
,
alignment:
Alignment
.
center
,),
],
)
...
...
netrain_flutter_app/lib/jishuaishuai/thirdVC.dart
View file @
2a777710
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/jishuaishuai/fourthVC.dart'
;
class
nextViewDemo
extends
StatelessWidget
{
...
...
@@ -7,13 +8,16 @@ class nextViewDemo extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
backgroundColor:
Colors
.
black26
,
appBar:
AppBar
(
title:
Text
(
"jss测试第三界面"
),
),
body:
Column
(
body:
Container
(
child:
Flex
(
direction:
Axis
.
vertical
,
children:
[
ElevatedButton
(
onPressed:
()
{
...
...
@@ -23,11 +27,132 @@ class nextViewDemo extends StatelessWidget {
},
child:
Text
(
"点击返回传值"
),
),
ElevatedButton
(
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
){
return
fourthDemo
();
},
settings:
RouteSettings
(
name:
"thirdVC"
)
)
);
},
child:
Container
(
child:
Text
(
"点击进入第四个页面"
),
)
),
listViewDemo
(),
WarpDemo
(),
],
),
)
);
}
}
class
listViewDemo
extends
StatefulWidget
{
listViewDemo
({
Key
key
})
:
super
(
key:
key
);
@override
_listViewDemoState
createState
()
{
return
_listViewDemoState
(
);
}
}
class
_listViewDemoState
extends
State
<
listViewDemo
>
{
@override
void
initState
()
{
super
.
initState
();
//创建时
}
@override
void
dispose
()
{
//销毁时
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
return
Container
(
width:
600
,
height:
300
,
color:
Colors
.
grey
,
child:
Align
(
alignment:
Alignment
(-
0.5
,
0.5
),
child:
Stack
(
alignment:
AlignmentDirectional
.
topStart
,
children:
[
Container
(
width:
100
,
height:
100
,
color:
Colors
.
orange
,
),
Positioned
(
left:
20
,
right:
30
,
top:
10
,
bottom:
20
,
child:
Container
(
color:
Colors
.
red
,
)),
],
),
)
);
}
}
class
WarpDemo
extends
StatefulWidget
{
WarpDemo
({
Key
key
})
:
super
(
key:
key
);
@override
_WarpDemoState
createState
()
{
return
_WarpDemoState
();
}
}
class
_WarpDemoState
extends
State
<
WarpDemo
>
{
List
<
int
>
listArr
=
List
();
@override
void
initState
()
{
super
.
initState
();
for
(
var
i
=
0
;
i
<
10
;
i
++){
listArr
.
add
(
i
);
}
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
return
Wrap
(
// spacing: 10.0,
runAlignment:
WrapAlignment
.
center
,
// runSpacing: 1,
children:
listArr
.
map
((
e
)
=>
Container
(
height:
100
,
width:
100
,
child:
Text
(
e
.
toString
()),
color:
Colors
.
blue
,
)).
toList
(
)
);
}
}
\ No newline at end of file
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