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
0
Merge Requests
0
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
71e6138c
Commit
71e6138c
authored
Mar 31, 2020
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Git pick master
parent
6f5b360b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
7 deletions
+77
-7
Frequently Asked Question.md
Frequently Asked Question.md
+37
-3
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
...src/main/java/com/idlefish/flutterboost/FlutterBoost.java
+3
-0
android/src/main/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
...in/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
+4
-0
android/src/main/java/com/idlefish/flutterboost/containers/FlutterFragment.java
...com/idlefish/flutterboost/containers/FlutterFragment.java
+33
-4
No files found.
Frequently Asked Question.md
View file @
71e6138c
...
...
@@ -42,13 +42,13 @@ bool isTopContainer = FlutterBoost.BoostContainer.of(context).onstage
回答:官方的解决方案仅仅是在native侧对FlutterViewController和Flutterengine进行解耦,如此可以一个FlutterEngine切换不同的FlutterViewController或者Activity进行渲染。但其并未解决Native和Flutter页面混合的问题,无法保证两侧的页面生命周期一致。即使是Flutter官方针对这个问题也是建议使用FlutterBoost。
其差别主要有:
|
*
|FlutterBoost
1.5
|Flutter官方方案 |其他框架|
|
*
|FlutterBoost
2.0
|Flutter官方方案 |其他框架|
|----|----|----|----|
|是否支持混合页面之间随意跳转 |Y |N |Y|
|一致的页面生命周期管理(多Flutter页面) |Y |N |?|
|是否支持页面间数据传递(回传等) |Y |N |N|
|是否支持测滑手势 |Y |Y |Y|
|是否支持跨页的hero动画 |
N
|Y |N|
|是否支持跨页的hero动画 |
Y
|Y |N|
|内存等资源占用是否可控 |Y |Y |Y|
|是否提供一致的页面route方案 |Y |Y |N|
|iOS和Android能力及接口是否一致 |Y |N |N|
...
...
@@ -57,6 +57,40 @@ bool isTopContainer = FlutterBoost.BoostContainer.of(context).onstage
同时FlutterBoost也提供了一次性创建混合工程的命令:flutterboot。代码参考:https://github.com/alibaba-flutter/flutter-boot
### 如果我需要通过FlutterViewController再弹出一个新的但frame比较小的FlutterViewController,应该怎么实现?
###
7.
如果我需要通过FlutterViewController再弹出一个新的但frame比较小的FlutterViewController,应该怎么实现?
回答:如果不加处理会遇到window大小变化的问题,但可以解决。具体可以参考这个issue:https://github.com/alibaba/flutter_boost/issues/435
### 8. Flutter ViewController如何设置横屏
VC设置横屏依赖于NavigationController或者rootVC。可以通过一下方式来设置:
1.
dart层的SystemChrome.setPreferredOrientations函数并非直接设置转向,而是设置页面优先使用的转向(preferred)
2.
app的转向控制除了info.plist的设置外,主要受UIWindow.rootViewController控制。大概过程是这样的:硬件检测到转向,就会调用UIWindow的转向函数,然后调用其rootViewController的shouldAutorotate判断是否需要自动转,然后取supportedInterfaceOrientations和info.plist中设置的交集来判断可否转
3.
对于UIViewController中的转向,也只在rootviewcontroller中才有效
举例如下,实现步骤可以这样:
1.
重写NavigationController:
```
objc
-
(
BOOL
)
shouldAutorotate
{
// id currentViewController = self.topViewController;
//
//
// if ([currentViewController isKindOfClass:[FlutterViewController class]])
// return [currentViewController shouldAutorotate];
return
YES
;
}
-
(
UIInterfaceOrientationMask
)
supportedInterfaceOrientations
{
id
currentViewController
=
self
.
topViewController
;
if
([
currentViewController
isKindOfClass
:[
FlutterViewController
class
]]){
NSLog
(
@"[XDEBUG]----fvc supported:%ld
\n
"
,[
currentViewController
supportedInterfaceOrientations
]);
return
[
currentViewController
supportedInterfaceOrientations
];
}
return
UIInterfaceOrientationMaskAll
;
}
```
2.
改dart层:因为SystemChrome.setPreferredOrientations的设置是全局的,但混合栈是多页面,所以在main函数中设置,后面在新建一个FlutterViewController时会被冲掉。为了解决这个问题,需要在每个dart页面的build处都加上这语句来设置每个页面能支持哪些转向类型
### 9. FlutterBoost for flutter1.12出现和surface相关的crash。可以参考这个issue:https://github.com/flutter/flutter/issues/52455
可能flutter engine的bug引起
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
View file @
71e6138c
...
...
@@ -5,6 +5,9 @@ import android.app.Activity;
import
android.app.Application
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.os.Debug
;
import
androidx.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.idlefish.flutterboost.interfaces.*
;
...
...
android/src/main/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
View file @
71e6138c
package
com.idlefish.flutterboost
;
import
android.support.annotation.Nullable
;
import
android.os.Handler
;
import
android.util.Log
;
import
androidx.annotation.Nullable
;
import
android.util.Log
;
import
com.idlefish.flutterboost.interfaces.IContainerRecord
;
...
...
android/src/main/java/com/idlefish/flutterboost/containers/FlutterFragment.java
View file @
71e6138c
...
...
@@ -2,6 +2,9 @@ package com.idlefish.flutterboost.containers;
import
android.app.Activity
;
import
android.arch.lifecycle.Lifecycle
;
import
android.graphics.Color
;
import
android.view.*
;
import
androidx.lifecycle.Lifecycle
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Build
;
...
...
@@ -253,20 +256,33 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
configureStatusBarForFullscreenFlutterExperience
();
return
delegate
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
}
private
void
configureStatusBarForFullscreenFlutterExperience
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
this
.
getActivity
().
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
Color
.
TRANSPARENT
);
window
.
getDecorView
().
setSystemUiVisibility
(
PlatformPlugin
.
DEFAULT_SYSTEM_UI
|
View
.
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
);
}
}
@Override
public
void
onStart
()
{
super
.
onStart
();
if
(!
isHidden
())
{
delegate
.
onStart
();
}
}
@Override
public
void
onResume
()
{
super
.
onResume
();
if
(!
isHidden
())
{
delegate
.
onResume
();
}
}
// TODO(mattcarroll): determine why this can't be in onResume(). Comment reason, or move if possible.
@ActivityCallThrough
...
...
@@ -277,14 +293,18 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
@Override
public
void
onPause
()
{
super
.
onPause
();
if
(!
isHidden
())
{
delegate
.
onPause
();
}
}
@Override
public
void
onStop
()
{
super
.
onStop
();
if
(!
isHidden
())
{
delegate
.
onStop
();
}
}
@Override
public
void
onDestroyView
()
{
...
...
@@ -300,6 +320,15 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
delegate
=
null
;
}
@Override
public
void
onHiddenChanged
(
boolean
hidden
)
{
super
.
onHiddenChanged
(
hidden
);
if
(
hidden
)
{
delegate
.
onPause
();
}
else
{
delegate
.
onResume
();
}
}
@ActivityCallThrough
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
...
...
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