Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
flutter_boost_1.22.4
Commits
a8ba6798
Commit
a8ba6798
authored
Oct 24, 2019
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add。Platform view demo
parent
e6f711a1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
6 deletions
+96
-6
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+3
-4
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/TextPlatformViewPlugin.java
.../idlefish/flutterboostexample/TextPlatformViewPlugin.java
+3
-2
example/lib/main.dart
example/lib/main.dart
+1
-0
example/lib/platform_view.dart
example/lib/platform_view.dart
+51
-0
example/lib/simple_page_widgets.dart
example/lib/simple_page_widgets.dart
+38
-0
No files found.
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
a8ba6798
...
...
@@ -5,12 +5,10 @@ import android.content.Context;
import
android.util.Log
;
import
com.idlefish.flutterboost.*
;
import
com.idlefish.flutterboost.interfaces.IContainerRecord
;
import
java.util.Map
;
import
com.idlefish.flutterboost.interfaces.INativeRouter
;
import
io.flutter.app.FlutterApplication
;
import
io.flutter.plugin.common.MethodChannel
;
public
class
MyApplication
extends
Application
{
...
...
@@ -36,8 +34,10 @@ public class MyApplication extends Application {
@Override
public
void
onPluginsRegistered
()
{
MethodChannel
mMethodChannel
=
new
MethodChannel
(
NewFlutterBoost
.
instance
().
engineProvider
().
getDartExecutor
(),
"
boosttest
"
);
MethodChannel
mMethodChannel
=
new
MethodChannel
(
NewFlutterBoost
.
instance
().
engineProvider
().
getDartExecutor
(),
"
methodChannel
"
);
Log
.
e
(
"MyApplication"
,
"MethodChannel create"
);
TextPlatformViewPlugin
.
register
(
NewFlutterBoost
.
instance
().
getPluginRegistry
().
registrarFor
(
"TextPlatformViewPlugin"
));
}
@Override
...
...
@@ -56,6 +56,5 @@ public class MyApplication extends Application {
}
}
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/TextPlatformViewPlugin.java
View file @
a8ba6798
package
com.taobao.idlefish.flutterboostexample
;
import
io.flutter.app.FlutterPluginRegistry
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.plugin.common.StandardMessageCodec
;
public
class
TextPlatformViewPlugin
{
public
static
void
register
(
FlutterPluginRegistry
registry
)
{
registr
y
.
getPlatformViewsController
().
get
Registry
().
registerViewFactory
(
"plugins.test/view"
,
public
static
void
register
(
PluginRegistry
.
Registrar
registrar
)
{
registr
ar
.
platformView
Registry
().
registerViewFactory
(
"plugins.test/view"
,
new
TextPlatformViewFactory
(
StandardMessageCodec
.
INSTANCE
));
}
}
example/lib/main.dart
View file @
a8ba6798
...
...
@@ -20,6 +20,7 @@ class _MyAppState extends State<MyApp> {
'first'
:
(
pageName
,
params
,
_
)
=>
FirstRouteWidget
(),
'second'
:
(
pageName
,
params
,
_
)
=>
SecondRouteWidget
(),
'tab'
:
(
pageName
,
params
,
_
)
=>
TabRouteWidget
(),
'platformView'
:
(
pageName
,
params
,
_
)
=>
PlatformRouteWidget
(),
'flutterFragment'
:
(
pageName
,
params
,
_
)
=>
FragmentRouteWidget
(
params
),
///可以在native层通过 getContainerParams 来传递参数
'flutterPage'
:
(
pageName
,
params
,
_
)
{
...
...
example/lib/platform_view.dart
0 → 100644
View file @
a8ba6798
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
typedef
void
TextViewCreatedCallback
(
TextViewController
controller
);
class
TextView
extends
StatefulWidget
{
const
TextView
({
Key
key
,
this
.
onTextViewCreated
,
})
:
super
(
key:
key
);
final
TextViewCreatedCallback
onTextViewCreated
;
@override
State
<
StatefulWidget
>
createState
()
=>
_TextViewState
();
}
class
_TextViewState
extends
State
<
TextView
>
{
@override
Widget
build
(
BuildContext
context
)
{
if
(
defaultTargetPlatform
==
TargetPlatform
.
android
)
{
return
AndroidView
(
viewType:
'plugins.test/view'
,
onPlatformViewCreated:
_onPlatformViewCreated
,
);
}
return
Text
(
'
$defaultTargetPlatform
is not yet supported by the text_view plugin'
);
}
void
_onPlatformViewCreated
(
int
id
)
{
if
(
widget
.
onTextViewCreated
==
null
)
{
return
;
}
widget
.
onTextViewCreated
(
new
TextViewController
.
_
(
id
));
}
}
class
TextViewController
{
TextViewController
.
_
(
int
id
)
:
_channel
=
new
MethodChannel
(
'plugins.felix.angelov/textview_
$id
'
);
final
MethodChannel
_channel
;
Future
<
void
>
setText
(
String
text
)
async
{
assert
(
text
!=
null
);
return
_channel
.
invokeMethod
(
'setText'
,
text
);
}
}
\ No newline at end of file
example/lib/simple_page_widgets.dart
View file @
a8ba6798
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter_boost_example/platform_view.dart'
;
class
FirstRouteWidget
extends
StatelessWidget
{
@override
...
...
@@ -68,6 +69,28 @@ class TabRouteWidget extends StatelessWidget {
}
}
class
PlatformRouteWidget
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"Platform Route"
),
),
body:
Center
(
child:
RaisedButton
(
child:
TextView
(),
onPressed:
()
{
print
(
"open second page!"
);
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
value
)
{
print
(
"call me when page is finished. did recieve second route result
$value
"
);
});
},
),
),
);
}
}
class
FlutterRouteWidget
extends
StatefulWidget
{
FlutterRouteWidget
({
this
.
params
,
this
.
message
});
final
Map
params
;
...
...
@@ -216,6 +239,21 @@ class _FlutterRouteWidgetState extends State<FlutterRouteWidget> {
MaterialPageRoute
(
builder:
(
_
)
=>
PushWidget
()));
},
),
InkWell
(
child:
Container
(
padding:
const
EdgeInsets
.
all
(
8.0
),
margin:
const
EdgeInsets
.
all
(
8.0
),
color:
Colors
.
yellow
,
child:
Text
(
'push Platform demo'
,
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
)),
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
_
)
=>
PlatformRouteWidget
()));
},
),
InkWell
(
child:
Container
(
padding:
const
EdgeInsets
.
all
(
8.0
),
...
...
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