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
0d913eab
Commit
0d913eab
authored
Feb 19, 2019
by
ouxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add assets channel
parent
cd6b1d7d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
assetsChannel.dart
lib/assetsChannel.dart
+81
-0
No files found.
lib/assetsChannel.dart
0 → 100644
View file @
0d913eab
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
(
'GMAssetsMethodChannelName'
);
static
const
EventChannel
eventChannel
=
EventChannel
(
'GMAssetsEventChannelName'
);
String
_batteryLevel
=
'Battery level: unknown.'
;
ByteData
_imageData
;
Future
<
void
>
_editPortrait
()
async
{
String
batteryLevel
;
try
{
final
int
result
=
await
methodChannel
.
invokeMethod
(
'editPortrait'
);
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
)
{
_imageData
=
event
;
print
(
event
.
runtimeType
);
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
(
_batteryLevel
,
key:
const
Key
(
'editPortrait'
)),
Padding
(
padding:
const
EdgeInsets
.
all
(
16.0
),
child:
RaisedButton
(
child:
const
Text
(
'editPortrait'
),
onPressed:
_editPortrait
,
),
),
],
),
],
),
),
),
);
}
}
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