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
1141c9a2
Commit
1141c9a2
authored
Dec 16, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qqq
parent
18acfa0a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
1340 deletions
+0
-1340
animationTest.dart
lib/commonModel/testPage/animationTest.dart
+0
-912
applicationTest.dart
lib/commonModel/testPage/applicationTest.dart
+0
-65
assetsChannel.dart
lib/commonModel/testPage/assetsChannel.dart
+0
-99
battery.dart
lib/commonModel/testPage/battery.dart
+0
-83
layoutTest.dart
lib/commonModel/testPage/layoutTest.dart
+0
-113
netWorkTest.dart
lib/commonModel/testPage/netWorkTest.dart
+0
-68
No files found.
lib/commonModel/testPage/animationTest.dart
deleted
100644 → 0
View file @
18acfa0a
import
'dart:async'
;
import
'dart:core'
;
import
'dart:math'
as
math
;
import
'package:flutter/material.dart'
;
class
AnimationPage
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_AnimationPageState
();
}
}
class
_AnimationPageState
extends
State
<
AnimationPage
>
with
TickerProviderStateMixin
{
int
_aniIndex
=
0
;
Widget
_buildAnimation
()
{
Widget
widget
;
switch
(
_aniIndex
)
{
case
0
:
widget
=
new
OpacityAniWidget
();
break
;
case
1
:
widget
=
new
MovementAniWidget
();
break
;
case
2
:
widget
=
new
RadiusAniWidget
();
break
;
case
3
:
widget
=
new
ColorAniWidget
();
break
;
case
4
:
widget
=
new
RotateAniWidget
();
break
;
case
5
:
widget
=
new
DeformAniWidget
();
break
;
case
6
:
widget
=
new
StaggeredAniWidget
();
break
;
}
return
widget
;
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
"Animation"
),
centerTitle:
true
,
),
body:
new
Column
(
children:
<
Widget
>[
new
Row
(
children:
<
Widget
>[
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
RaisedButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'opacity'
),
onPressed:
()
{
setState
(()
{
_aniIndex
=
0
;
});
}),
),
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
RaisedButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'movement'
),
onPressed:
()
{
setState
(()
{
_aniIndex
=
1
;
});
}),
),
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
RaisedButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'radius'
),
onPressed:
()
{
setState
(()
{
_aniIndex
=
2
;
});
}),
),
],
),
new
Row
(
children:
<
Widget
>[
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
RaisedButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'color'
),
onPressed:
()
{
setState
(()
{
_aniIndex
=
3
;
});
}),
),
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
RaisedButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'rotate'
),
onPressed:
()
{
setState
(()
{
_aniIndex
=
4
;
});
}),
),
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
RaisedButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'deform'
),
onPressed:
()
{
setState
(()
{
_aniIndex
=
5
;
});
}),
),
],
),
new
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
RaisedButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'Staggered'
),
onPressed:
()
{
setState
(()
{
_aniIndex
=
6
;
});
}),
),
],
),
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
_buildAnimation
(),
),
],
),
);
}
}
class
OpacityAniWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_OpacityAniWidgetState
();
}
}
class
_OpacityAniWidgetState
extends
State
<
OpacityAniWidget
>
with
TickerProviderStateMixin
{
AnimationController
_controller
;
Animation
<
double
>
opacity
;
void
_initController
()
{
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
2000
),
vsync:
this
,
);
}
void
_initAni
()
{
opacity
=
Tween
<
double
>(
begin:
0.0
,
end:
1.0
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.0
,
0.5
,
curve:
Curves
.
easeIn
,
),
),
)
..
addListener
(()
{
setState
(()
{});
})
..
addStatusListener
((
AnimationStatus
status
)
{
print
(
status
);
});
}
Future
_startAnimation
()
async
{
try
{
await
_controller
.
repeat
();
//
// await _controller
// .forward()
// .orCancel;
// await _controller
// .reverse()
// .orCancel;
}
on
TickerCanceled
{
print
(
'Animation Failed'
);
}
}
@override
void
initState
()
{
super
.
initState
();
_initController
();
_initAni
();
_startAnimation
();
}
@override
void
dispose
()
{
_controller
?.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Opacity
(
opacity:
opacity
.
value
,
child:
new
Container
(
color:
Colors
.
red
,
height:
200.0
,
width:
200.0
,
child:
new
Center
(
child:
new
Text
(
'opacity'
,
style:
new
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
),
),
),
),
);
}
}
class
MovementAniWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_MovementAniWidgetState
();
}
}
class
_MovementAniWidgetState
extends
State
<
MovementAniWidget
>
with
TickerProviderStateMixin
{
AnimationController
_controller
;
Animation
<
EdgeInsets
>
movement
;
void
_initController
()
{
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
5000
),
vsync:
this
,
);
}
void
_initAni
()
{
movement
=
EdgeInsetsTween
(
begin:
EdgeInsets
.
only
(
top:
0.0
,
right:
0.0
),
end:
EdgeInsets
.
only
(
top:
50.0
,
right:
100.0
),
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.1
,
0.5
,
curve:
Curves
.
fastOutSlowIn
,
),
),
)
..
addListener
(()
{
setState
(()
{});
})
..
addStatusListener
((
AnimationStatus
status
)
{
print
(
status
);
});
}
Future
_startAnimation
()
async
{
try
{
await
_controller
.
repeat
();
// await _controller
// .forward()
// .orCancel;
// await _controller
// .reverse()
// .orCancel;
}
on
TickerCanceled
{
print
(
'Animation Failed'
);
}
}
@override
void
initState
()
{
super
.
initState
();
_initController
();
_initAni
();
_startAnimation
();
}
@override
void
dispose
()
{
_controller
?.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Container
(
color:
Colors
.
blue
,
height:
200.0
,
width:
200.0
,
padding:
movement
.
value
,
child:
new
Center
(
child:
new
Text
(
'movement'
,
style:
new
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
),
),
),
);
}
}
class
RadiusAniWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_RadiusAniWidgetState
();
}
}
class
_RadiusAniWidgetState
extends
State
<
RadiusAniWidget
>
with
TickerProviderStateMixin
{
AnimationController
_controller
;
Animation
<
BorderRadius
>
radius
;
void
_initController
()
{
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
2000
),
vsync:
this
,
);
}
void
_initAni
()
{
radius
=
radius
=
BorderRadiusTween
(
begin:
BorderRadius
.
circular
(
0.0
),
end:
BorderRadius
.
circular
(
100.0
),
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.5
,
0.8
,
curve:
Curves
.
ease
,
),
),
)
..
addListener
(()
{
setState
(()
{});
})
..
addStatusListener
((
AnimationStatus
status
)
{
print
(
status
);
});
}
Future
_startAnimation
()
async
{
try
{
await
_controller
.
repeat
();
// await _controller
// .forward()
// .orCancel;
// await _controller
// .reverse()
// .orCancel;
}
on
TickerCanceled
{
print
(
'Animation Failed'
);
}
}
@override
void
initState
()
{
super
.
initState
();
_initController
();
_initAni
();
_startAnimation
();
}
@override
void
dispose
()
{
_controller
?.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Container
(
height:
200.0
,
width:
200.0
,
child:
new
Center
(
child:
new
Text
(
'radius'
,
style:
new
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
),
),
),
decoration:
BoxDecoration
(
color:
Colors
.
purple
,
border:
Border
.
all
(
color:
Colors
.
purple
,
width:
2.0
,
),
borderRadius:
radius
.
value
,
),
);
}
}
class
ColorAniWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_ColorAniWidgetState
();
}
}
class
_ColorAniWidgetState
extends
State
<
ColorAniWidget
>
with
TickerProviderStateMixin
{
AnimationController
_controller
;
Animation
<
Color
>
color
;
void
_initController
()
{
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
2000
),
vsync:
this
,
);
}
void
_initAni
()
{
color
=
ColorTween
(
begin:
Colors
.
red
[
100
],
end:
Colors
.
blue
[
900
],
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.0
,
1.0
,
curve:
Curves
.
linear
,
),
),
)
..
addListener
(()
{
setState
(()
{});
})
..
addStatusListener
((
AnimationStatus
status
)
{
print
(
status
);
});
}
Future
_startAnimation
()
async
{
try
{
await
_controller
.
repeat
();
// await _controller
// .forward()
// .orCancel;
// await _controller
// .reverse()
// .orCancel;
}
on
TickerCanceled
{
print
(
'Animation Failed'
);
}
}
@override
void
initState
()
{
super
.
initState
();
_initController
();
_initAni
();
_startAnimation
();
}
@override
void
dispose
()
{
_controller
?.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Container
(
color:
color
.
value
,
height:
200.0
,
width:
200.0
,
child:
new
Center
(
child:
new
Text
(
'color'
,
style:
new
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
),
),
),
);
}
}
class
RotateAniWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_RotateAniWidgetState
();
}
}
class
_RotateAniWidgetState
extends
State
<
RotateAniWidget
>
with
TickerProviderStateMixin
{
AnimationController
_controller
;
Animation
<
double
>
rotate
;
void
_initController
()
{
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
2000
),
vsync:
this
,
);
}
void
_initAni
()
{
rotate
=
Tween
<
double
>(
begin:
0.0
,
end:
math
.
pi
*
2
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.1
,
0.3
,
curve:
Curves
.
ease
,
),
),
)
..
addListener
(()
{
setState
(()
{});
})
..
addStatusListener
((
AnimationStatus
status
)
{
print
(
status
);
});
}
Future
_startAnimation
()
async
{
try
{
await
_controller
.
repeat
();
// await _controller
// .forward()
// .orCancel;
// await _controller
// .reverse()
// .orCancel;
}
on
TickerCanceled
{
print
(
'Animation Failed'
);
}
}
@override
void
initState
()
{
super
.
initState
();
_initController
();
_initAni
();
_startAnimation
();
}
@override
void
dispose
()
{
_controller
?.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Container
(
height:
200.0
,
width:
200.0
,
color:
Colors
.
green
,
transform:
Matrix4
.
identity
()..
rotateZ
(
rotate
.
value
),
child:
new
Center
(
child:
new
Text
(
'rotate'
,
style:
new
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
),
),
),
);
}
}
class
DeformAniWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_DeformAniWidgetState
();
}
}
class
_DeformAniWidgetState
extends
State
<
DeformAniWidget
>
with
TickerProviderStateMixin
{
AnimationController
_controller
;
Animation
<
double
>
width
;
Animation
<
double
>
height
;
void
_initController
()
{
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
2000
),
vsync:
this
,
);
}
void
_initAni
()
{
height
=
Tween
<
double
>(
begin:
100.0
,
end:
200.0
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.3
,
0.6
,
curve:
Curves
.
fastOutSlowIn
,
),
),
)
..
addListener
(()
{
setState
(()
{});
})
..
addStatusListener
((
AnimationStatus
status
)
{
print
(
status
);
});
width
=
Tween
<
double
>(
begin:
100.0
,
end:
200.0
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.4
,
0.6
,
curve:
Curves
.
fastOutSlowIn
,
),
),
)
..
addListener
(()
{
setState
(()
{});
})
..
addStatusListener
((
AnimationStatus
status
)
{
print
(
status
);
});
}
Future
_startAnimation
()
async
{
try
{
await
_controller
.
repeat
();
// await _controller
// .forward()
// .orCancel;
// await _controller
// .reverse()
// .orCancel;
}
on
TickerCanceled
{
print
(
'Animation Failed'
);
}
}
@override
void
initState
()
{
super
.
initState
();
_initController
();
_initAni
();
_startAnimation
();
}
@override
void
dispose
()
{
_controller
?.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Container
(
width:
width
.
value
,
height:
height
.
value
,
color:
Colors
.
deepPurple
,
child:
new
Center
(
child:
new
Text
(
'deform'
,
style:
new
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
),
),
),
);
}
}
class
StaggeredAniWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_StaggeredAniWidgetState
();
}
}
class
_StaggeredAniWidgetState
extends
State
<
StaggeredAniWidget
>
with
TickerProviderStateMixin
{
AnimationController
_controller
;
Animation
<
double
>
opacity
;
Animation
<
EdgeInsets
>
movement
;
Animation
<
Color
>
color
;
Animation
<
BorderRadius
>
radius
;
Animation
<
double
>
rotate
;
Animation
<
double
>
width
;
Animation
<
double
>
height
;
void
_initController
()
{
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
2000
),
vsync:
this
,
);
}
void
_initAni
()
{
opacity
=
Tween
<
double
>(
begin:
0.0
,
end:
1.0
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.0
,
0.1
,
curve:
Curves
.
easeIn
,
),
),
);
rotate
=
Tween
<
double
>(
begin:
0.0
,
end:
math
.
pi
*
2
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.0
,
0.2
,
curve:
Curves
.
ease
,
),
),
);
movement
=
EdgeInsetsTween
(
begin:
EdgeInsets
.
only
(
top:
0.0
),
end:
EdgeInsets
.
only
(
top:
100.0
),
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.2
,
0.375
,
curve:
Curves
.
fastOutSlowIn
,
),
),
);
color
=
ColorTween
(
begin:
Colors
.
blue
[
300
],
end:
Colors
.
blue
[
900
],
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.5
,
0.75
,
curve:
Curves
.
linear
,
),
),
);
radius
=
BorderRadiusTween
(
begin:
BorderRadius
.
circular
(
0.0
),
end:
BorderRadius
.
circular
(
100.0
),
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.5
,
0.75
,
curve:
Curves
.
ease
,
),
),
);
height
=
Tween
<
double
>(
begin:
100.0
,
end:
200.0
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.375
,
0.6
,
curve:
Curves
.
fastOutSlowIn
,
),
),
);
width
=
Tween
<
double
>(
begin:
100.0
,
end:
200.0
,
).
animate
(
CurvedAnimation
(
parent:
_controller
,
curve:
Interval
(
0.375
,
0.6
,
curve:
Curves
.
fastOutSlowIn
,
),
),
);
}
Future
_startAnimation
()
async
{
try
{
// await _controller.repeat();
await
_controller
.
forward
().
orCancel
;
await
_controller
.
reverse
().
orCancel
;
}
on
TickerCanceled
{
print
(
'Animation Failed'
);
}
}
@override
void
initState
()
{
super
.
initState
();
_initController
();
_initAni
();
_startAnimation
();
}
@override
void
dispose
()
{
_controller
?.
dispose
();
super
.
dispose
();
}
Widget
_buildAni
(
BuildContext
context
,
Widget
child
)
{
return
new
Container
(
padding:
movement
.
value
,
transform:
Matrix4
.
identity
()..
rotateZ
(
rotate
.
value
),
child:
new
Opacity
(
opacity:
opacity
.
value
,
child:
new
Container
(
width:
width
.
value
,
height:
height
.
value
,
decoration:
new
BoxDecoration
(
color:
color
.
value
,
border:
new
Border
.
all
(
color:
Colors
.
black
,
width:
3.0
,
),
borderRadius:
radius
.
value
,
),
child:
new
Center
(
child:
new
Text
(
'staggered'
,
style:
new
TextStyle
(
color:
Colors
.
white
,
fontSize:
16.0
),
),
),
),
),
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
new
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
10.0
,
top:
10.0
,
right:
10.0
),
child:
new
FlatButton
(
textColor:
Colors
.
black
,
child:
new
Text
(
'replay staggered'
),
onPressed:
()
{
_startAnimation
();
}),
),
new
AnimatedBuilder
(
animation:
_controller
,
builder:
_buildAni
)
],
);
}
}
lib/commonModel/testPage/applicationTest.dart
deleted
100644 → 0
View file @
18acfa0a
import
'package:flutter/material.dart'
;
import
'animationTest.dart'
;
import
'layoutTest.dart'
;
class
MyApplicaitonTest
extends
StatefulWidget
{
@override
_MyApplicaitonTestState
createState
()
=>
_MyApplicaitonTestState
();
}
class
_MyApplicaitonTestState
extends
State
<
MyApplicaitonTest
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'Flutter Demo'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
),
home:
WidgetA
(),
routes:
{
"/layouttest"
:
layoutTestPage
,
},
);
}
Widget
layoutTestPage
(
BuildContext
context
)
{
return
LayoutTest
();
}
}
class
WidgetA
extends
StatefulWidget
{
final
Widget
child
;
WidgetA
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
_WidgetAState
createState
()
=>
_WidgetAState
();
}
class
_WidgetAState
extends
State
<
WidgetA
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'text'
),
),
body:
Container
(
padding:
EdgeInsets
.
all
(
32.0
),
child:
Center
(
child:
Column
(
children:
<
Widget
>[
Center
(
child:
FlatButton
(
child:
Text
(
'hit me'
),
onPressed:
(){
Navigator
.
of
(
context
).
pushNamed
(
"/layouttest"
);
},
),
)
],
),
),
),
);
}
}
\ No newline at end of file
lib/commonModel/testPage/assetsChannel.dart
deleted
100644 → 0
View file @
18acfa0a
import
'dart:async'
;
import
'dart:typed_data'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
class
AssestPlatformChannel
extends
StatefulWidget
{
@override
_AssestPlatformChannelState
createState
()
=>
_AssestPlatformChannelState
();
}
class
_AssestPlatformChannelState
extends
State
<
AssestPlatformChannel
>
{
static
const
MethodChannel
methodChannel
=
MethodChannel
(
'GMAssetsMethodChannelName'
);
static
const
EventChannel
eventChannel
=
EventChannel
(
'GMAssetsEventChannelName'
);
Uint8List
_imageData
;
String
_tttt
=
'ssss'
;
Future
<
void
>
_editPortrait
()
async
{
Uint8List
imageData
;
try
{
final
result
=
await
methodChannel
.
invokeMethod
(
'editPortrait'
);
imageData
=
result
;
}
on
PlatformException
{
imageData
=
null
;
}
setState
(()
{
_imageData
=
imageData
;
_tttt
=
_imageData
.
runtimeType
.
toString
();
});
}
@override
void
initState
()
{
super
.
initState
();
eventChannel
.
receiveBroadcastStream
().
listen
(
_onEvent
,
onError:
_onError
);
}
void
_onEvent
(
Object
event
)
{
setState
(()
{});
}
void
_onError
(
Object
error
)
{
setState
(()
{});
}
@override
Widget
build
(
BuildContext
context
)
{
return
Material
(
child:
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'editPortrait test'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Text
(
_tttt
,
key:
const
Key
(
'editPortrait'
)),
Padding
(
padding:
const
EdgeInsets
.
all
(
16.0
),
child:
RaisedButton
(
child:
const
Text
(
'editPortrait'
),
onPressed:
_editPortrait
,
),
),
Container
(
color:
Colors
.
pink
[
300
],
width:
300
,
height:
300
,
child:
_imageWidget
()
)
],
),
],
),
),
),
);
}
Widget
_imageWidget
(){
if
(
_imageData
!=
null
)
{
return
Image
.
memory
(
_imageData
,
width:
200
,
height:
200
,
);
}
else
{
return
Center
(
child:
Text
(
'I am not image'
+
_tttt
),
);
}
}
}
lib/commonModel/testPage/battery.dart
deleted
100644 → 0
View file @
18acfa0a
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
class
PlatformChannel
extends
StatefulWidget
{
@override
_PlatformChannelState
createState
()
=>
_PlatformChannelState
();
}
class
_PlatformChannelState
extends
State
<
PlatformChannel
>
{
static
const
MethodChannel
methodChannel
=
MethodChannel
(
'samples.flutter.io/battery'
);
static
const
EventChannel
eventChannel
=
EventChannel
(
'samples.flutter.io/charging'
);
String
_batteryLevel
=
'Battery level: unknown.'
;
String
_chargingStatus
=
'Battery status: unknown.'
;
Future
<
void
>
_getBatteryLevel
()
async
{
String
batteryLevel
;
try
{
final
int
result
=
await
methodChannel
.
invokeMethod
(
'getBatteryLevel'
);
batteryLevel
=
'Battery level:
$result
%.'
;
}
on
PlatformException
{
batteryLevel
=
'Failed to get battery level.'
;
}
setState
(()
{
_batteryLevel
=
batteryLevel
;
});
}
@override
void
initState
()
{
super
.
initState
();
eventChannel
.
receiveBroadcastStream
().
listen
(
_onEvent
,
onError:
_onError
);
}
void
_onEvent
(
Object
event
)
{
setState
(()
{
_chargingStatus
=
"Battery status:
${event == 'charging' ? '' : 'dis'}
charging."
;
});
}
void
_onError
(
Object
error
)
{
setState
(()
{
_chargingStatus
=
'Battery status: unknown.'
;
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
Material
(
child:
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Channel test'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Text
(
_batteryLevel
,
key:
const
Key
(
'Battery level label'
)),
Padding
(
padding:
const
EdgeInsets
.
all
(
16.0
),
child:
RaisedButton
(
child:
const
Text
(
'Refresh'
),
onPressed:
_getBatteryLevel
,
),
),
],
),
Text
(
_chargingStatus
),
],
),
),
),
);
}
}
lib/commonModel/testPage/layoutTest.dart
deleted
100644 → 0
View file @
18acfa0a
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
class
LayoutTest
extends
StatefulWidget
{
@override
_LayoutTestState
createState
()
=>
_LayoutTestState
();
}
class
_LayoutTestState
extends
State
<
LayoutTest
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Layout Test'
),
),
body:
Container
(
padding:
EdgeInsets
.
all
(
32.0
),
child:
Center
(
child:
Column
(
children:
<
Widget
>[
_renderBoxTest
(),
_containerTestWidget
()
],
),
),
),
);
}
Widget
_renderBoxTest
(
){
return
Container
(
color:
Colors
.
greenAccent
,
width:
double
.
infinity
,
constraints:
BoxConstraints
(
maxWidth:
double
.
infinity
,
minWidth:
200.0
,
maxHeight:
200
,
minHeight:
100.0
),
child:
Stingy
(
child:
Container
(
color:
Colors
.
pink
[
200
],
),
),
);
}
// www.baidu.com/img/bd_logo1.png
Widget
_containerTestWidget
(){
return
Container
(
constraints:
BoxConstraints
.
expand
(
height:
Theme
.
of
(
context
).
textTheme
.
display1
.
fontSize
*
1.1
+
200.0
,
),
padding:
const
EdgeInsets
.
all
(
8.0
),
color:
Colors
.
greenAccent
.
shade700
,
alignment:
Alignment
.
bottomCenter
,
child:
Text
(
'Hello World'
,
style:
Theme
.
of
(
context
).
textTheme
.
display1
.
copyWith
(
color:
Colors
.
orange
[
200
])),
foregroundDecoration:
BoxDecoration
(
image:
DecorationImage
(
image:
NetworkImage
(
'https://www.example.com/images/frame.png'
),
centerSlice:
Rect
.
fromLTRB
(
270.0
,
180.0
,
1360.0
,
730.0
),
),
),
transform:
Matrix4
.
rotationZ
(
0.1
),
);
}
}
class
Stingy
extends
SingleChildRenderObjectWidget
{
Stingy
({
Widget
child
})
:
super
(
child:
child
);
@override
RenderObject
createRenderObject
(
BuildContext
context
)
{
// TODO: implement createRenderObject
return
RenderStingy
();
}
}
class
RenderStingy
extends
RenderShiftedBox
{
RenderStingy
()
:
super
(
null
);
// 绘制方法
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
// TODO: implement paint
super
.
paint
(
context
,
offset
);
}
// 布局方法
@override
void
performLayout
()
{
// 布局 child 确定 child 的 size
child
.
layout
(
BoxConstraints
(
minHeight:
0.0
,
maxHeight:
constraints
.
minHeight
,
minWidth:
0.0
,
maxWidth:
constraints
.
minWidth
),
parentUsesSize:
true
);
print
(
'constraints:
$constraints
'
);
// child 的 Offset
final
BoxParentData
childParentData
=
child
.
parentData
;
childParentData
.
offset
=
Offset
(
constraints
.
maxWidth
-
child
.
size
.
width
,
constraints
.
maxHeight
-
child
.
size
.
height
);
print
(
'childParentData:
$childParentData
'
);
// 确定自己(父节点)的大小,并重绘父节点。不重设,不能触发重绘,例如在热重载的情景中,重设container.maxHeight,无效
size
=
Size
(
constraints
.
maxWidth
,
constraints
.
maxHeight
);
print
(
'size:
$size
'
);
}
}
lib/commonModel/testPage/netWorkTest.dart
deleted
100644 → 0
View file @
18acfa0a
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/commonModel/net/ALNetWork.dart'
;
void
main
(
)
=>
runApp
(
MaterialApp
(
home:
NetWorkTestPage
(),
));
class
NetWorkTestPage
extends
StatefulWidget
{
@override
_NetWorkTestPageState
createState
()
=>
_NetWorkTestPageState
();
}
class
_NetWorkTestPageState
extends
State
<
NetWorkTestPage
>
{
String
_string
=
'lalala'
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'NewtWork Test Page'
),
),
body:
Container
(
padding:
EdgeInsets
.
all
(
32.0
),
child:
Center
(
child:
Column
(
children:
<
Widget
>[
FlatButton
(
child:
Text
(
'newtWorkTest'
),
color:
Colors
.
greenAccent
,
onPressed:
_netWork
,
),
Container
(
color:
Colors
.
greenAccent
,
constraints:
BoxConstraints
(
maxWidth:
double
.
infinity
,
minWidth:
200.0
,
maxHeight:
500
,
minHeight:
200.0
),
child:
Text
(
'data:'
+
_string
),
),
],
),
),
),
);
}
void
_netWork
()
{
ALNetwork
(
success:
(
NetworkSuccess
success
){
print
(
success
.
data
);
setState
(()
{
_string
=
success
.
data
.
toString
();
});
},
error:
(
NetworkError
error
){
print
(
error
.
error
);
setState
(()
{
_string
=
error
.
error
.
toString
();
});
},
api:
'/api/v1/index'
)
..
excuteGet
();
}
}
\ 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