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
ef1f8f2d
Commit
ef1f8f2d
authored
Oct 25, 2019
by
余玠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现通过FlutterBoost销毁engine
parent
aa8d47d6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
24 deletions
+58
-24
example/ios/Runner/AppDelegate.h
example/ios/Runner/AppDelegate.h
+2
-2
example/ios/Runner/AppDelegate.m
example/ios/Runner/AppDelegate.m
+35
-12
example/ios/Runner/UIViewControllerDemo.xib
example/ios/Runner/UIViewControllerDemo.xib
+2
-2
ios/Classes/Boost/FlutterBoostPlugin.h
ios/Classes/Boost/FlutterBoostPlugin.h
+2
-0
ios/Classes/Boost/FlutterBoostPlugin.m
ios/Classes/Boost/FlutterBoostPlugin.m
+7
-2
ios/Classes/Boost/FlutterBoostPlugin_private.h
ios/Classes/Boost/FlutterBoostPlugin_private.h
+0
-1
ios/Classes/Engine/FLBFlutterEngine.m
ios/Classes/Engine/FLBFlutterEngine.m
+10
-5
No files found.
example/ios/Runner/AppDelegate.h
View file @
ef1f8f2d
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#import <flutter_boost/FlutterBoost.h>
#import <flutter_boost/FlutterBoost.h>
@interface
AppDelegate
:
FLBFlutterAppDelegate
<
UIApplicationDelegate
>
@interface
AppDelegate
:
UIResponder
<
UIApplicationDelegate
>
@property
(
strong
,
nonatomic
)
UIWindow
*
window
;
@end
@end
example/ios/Runner/AppDelegate.m
View file @
ef1f8f2d
...
@@ -19,12 +19,6 @@
...
@@ -19,12 +19,6 @@
-
(
BOOL
)
application
:(
UIApplication
*
)
application
didFinishLaunchingWithOptions
:(
NSDictionary
*
)
launchOptions
-
(
BOOL
)
application
:(
UIApplication
*
)
application
didFinishLaunchingWithOptions
:(
NSDictionary
*
)
launchOptions
{
{
PlatformRouterImp
*
router
=
[
PlatformRouterImp
new
];
[
FlutterBoostPlugin
.
sharedInstance
startFlutterWithPlatform
:
router
onStart:
^
(
FlutterEngine
*
engine
)
{
}];
self
.
window
=
[[
UIWindow
alloc
]
initWithFrame
:
[
UIScreen
mainScreen
].
bounds
];
self
.
window
=
[[
UIWindow
alloc
]
initWithFrame
:
[
UIScreen
mainScreen
].
bounds
];
...
@@ -35,17 +29,14 @@
...
@@ -35,17 +29,14 @@
vc
.
tabBarItem
=
[[
UITabBarItem
alloc
]
initWithTitle
:
@"hybrid"
image
:
nil
tag
:
0
];
vc
.
tabBarItem
=
[[
UITabBarItem
alloc
]
initWithTitle
:
@"hybrid"
image
:
nil
tag
:
0
];
FLBFlutterViewContainer
*
fvc
=
FLBFlutterViewContain
er
.
new
;
UIViewController
*
fvc
=
UIViewControll
er
.
new
;
[
fvc
setName
:
@"tab"
params
:@{}];
//
[fvc setName:@"tab" params:@{}];
fvc
.
tabBarItem
=
[[
UITabBarItem
alloc
]
initWithTitle
:
@"flutter_tab"
image
:
nil
tag
:
1
];
fvc
.
tabBarItem
=
[[
UITabBarItem
alloc
]
initWithTitle
:
@"flutter_tab"
image
:
nil
tag
:
1
];
UITabBarController
*
tabVC
=
[[
UITabBarController
alloc
]
init
];
UITabBarController
*
tabVC
=
[[
UITabBarController
alloc
]
init
];
UINavigationController
*
rvc
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
tabVC
];
UINavigationController
*
rvc
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
tabVC
];
router
.
navigationController
=
rvc
;
tabVC
.
viewControllers
=
@[
vc
,
fvc
];
tabVC
.
viewControllers
=
@[
vc
,
fvc
];
self
.
window
.
rootViewController
=
rvc
;
self
.
window
.
rootViewController
=
rvc
;
...
@@ -57,16 +48,48 @@
...
@@ -57,16 +48,48 @@
UIButton
*
nativeButton
=
[
UIButton
buttonWithType
:
UIButtonTypeCustom
];
UIButton
*
nativeButton
=
[
UIButton
buttonWithType
:
UIButtonTypeCustom
];
nativeButton
.
frame
=
CGRectMake
(
self
.
window
.
frame
.
size
.
width
*
0
.
5
-
50
,
200
,
10
0
,
45
);
nativeButton
.
frame
=
CGRectMake
(
self
.
window
.
frame
.
size
.
width
*
0
.
5
-
60
,
150
,
13
0
,
45
);
nativeButton
.
backgroundColor
=
[
UIColor
redColor
];
nativeButton
.
backgroundColor
=
[
UIColor
redColor
];
[
nativeButton
setTitle
:
@"push native"
forState
:
UIControlStateNormal
];
[
nativeButton
setTitle
:
@"push native"
forState
:
UIControlStateNormal
];
[
nativeButton
addTarget
:
self
action
:
@selector
(
pushNative
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
nativeButton
addTarget
:
self
action
:
@selector
(
pushNative
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
window
addSubview
:
nativeButton
];
[
self
.
window
addSubview
:
nativeButton
];
UIButton
*
startEngine
=
[
UIButton
buttonWithType
:
UIButtonTypeCustom
];
startEngine
.
frame
=
CGRectMake
(
self
.
window
.
frame
.
size
.
width
*
0
.
5
-
60
,
230
,
130
,
40
);
startEngine
.
backgroundColor
=
[
UIColor
redColor
];
[
startEngine
setTitle
:
@"start engine"
forState
:
UIControlStateNormal
];
[
startEngine
addTarget
:
self
action
:
@selector
(
startFlutter
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
window
addSubview
:
startEngine
];
UIButton
*
destroyEngine
=
[
UIButton
buttonWithType
:
UIButtonTypeCustom
];
destroyEngine
.
frame
=
CGRectMake
(
self
.
window
.
frame
.
size
.
width
*
0
.
5
-
60
,
300
,
130
,
40
);
destroyEngine
.
backgroundColor
=
[
UIColor
redColor
];
[
destroyEngine
setTitle
:
@"destroy engine"
forState
:
UIControlStateNormal
];
[
destroyEngine
addTarget
:
self
action
:
@selector
(
destroyFlutter
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
window
addSubview
:
destroyEngine
];
return
YES
;
return
YES
;
}
}
-
(
void
)
startFlutter
:(
id
)
sender
{
PlatformRouterImp
*
router
=
[
PlatformRouterImp
new
];
router
.
navigationController
=
(
UINavigationController
*
)
self
.
window
.
rootViewController
;
[
FlutterBoostPlugin
.
sharedInstance
startFlutterWithPlatform
:
router
onStart:
^
(
FlutterEngine
*
engine
)
{
}];
}
-
(
void
)
destroyFlutter
:(
id
)
sender
{
//切记:在destroyEngine前务必将所有FlutterViewController及其子类的实例销毁。在这里是FLBFlutterViewContainer。否则会异常;以下是全部步骤
//1. 首先通过为所有FlutterPlugin的methodChannel属性设为nil来接触其与FlutterEngine的间接强引用
//2. 销毁所有的FlutterViewController实例,来解除其与FlutterEngine的强引用
//3. 调用FlutterBoostPlugin.destroyEngine函数来解除与FlutterEngine的强引用
[
FlutterBoostPlugin
.
sharedInstance
destroyEngine
];
}
-
(
void
)
pushNative
-
(
void
)
pushNative
{
{
UINavigationController
*
nvc
=
(
id
)
self
.
window
.
rootViewController
;
UINavigationController
*
nvc
=
(
id
)
self
.
window
.
rootViewController
;
...
...
example/ios/Runner/UIViewControllerDemo.xib
View file @
ef1f8f2d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.XIB"
version=
"3.0"
toolsVersion=
"144
60.31
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
colorMatched=
"YES"
>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.XIB"
version=
"3.0"
toolsVersion=
"144
90.70
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
colorMatched=
"YES"
>
<device
id=
"retina4_7"
orientation=
"portrait"
>
<device
id=
"retina4_7"
orientation=
"portrait"
>
<adaptation
id=
"fullscreen"
/>
<adaptation
id=
"fullscreen"
/>
</device>
</device>
<dependencies>
<dependencies>
<deployment
identifier=
"iOS"
/>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"144
60.20
"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"144
90.49
"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
</dependencies>
<objects>
<objects>
...
...
ios/Classes/Boost/FlutterBoostPlugin.h
View file @
ef1f8f2d
...
@@ -108,4 +108,6 @@
...
@@ -108,4 +108,6 @@
exts
:(
NSDictionary
*
)
exts
exts
:(
NSDictionary
*
)
exts
onPageFinished
:(
void
(
^
)(
NSDictionary
*
))
resultCallback
onPageFinished
:(
void
(
^
)(
NSDictionary
*
))
resultCallback
completion
:(
void
(
^
)(
BOOL
))
completion
;
completion
:(
void
(
^
)(
BOOL
))
completion
;
-
(
void
)
destroyEngine
;
@end
@end
ios/Classes/Boost/FlutterBoostPlugin.m
View file @
ef1f8f2d
...
@@ -118,8 +118,8 @@
...
@@ -118,8 +118,8 @@
__weak
__typeof__
(
self
)
weakSelf
=
self
;
__weak
__typeof__
(
self
)
weakSelf
=
self
;
dispatch_once
(
&
onceToken
,
^
{
dispatch_once
(
&
onceToken
,
^
{
__strong
__typeof__
(
weakSelf
)
self
=
weakSelf
;
__strong
__typeof__
(
weakSelf
)
self
=
weakSelf
;
self
.
factory
=
FLBFactory
.
new
;
FLBFactory
*
factory
=
FLBFactory
.
new
;
self
.
application
=
[
self
->
_
factory
createApplication
:
platform
];
self
.
application
=
[
factory
createApplication
:
platform
];
[
self
.
application
startFlutterWithPlatform
:
platform
[
self
.
application
startFlutterWithPlatform
:
platform
onStart:
callback
];
onStart:
callback
];
});
});
...
@@ -169,4 +169,9 @@
...
@@ -169,4 +169,9 @@
id
<
FLBFlutterApplicationInterface
>
app
=
[[
FlutterBoostPlugin
sharedInstance
]
application
];
id
<
FLBFlutterApplicationInterface
>
app
=
[[
FlutterBoostPlugin
sharedInstance
]
application
];
[
app
close
:
uniqueId
result
:
resultData
exts
:
exts
completion
:
completion
];
[
app
close
:
uniqueId
result
:
resultData
exts
:
exts
completion
:
completion
];
}
}
-
(
void
)
destroyEngine
{
self
.
methodChannel
=
nil
;
self
.
application
=
nil
;
}
@end
@end
ios/Classes/Boost/FlutterBoostPlugin_private.h
View file @
ef1f8f2d
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#import "FlutterBoostPlugin.h"
#import "FlutterBoostPlugin.h"
@interface
FlutterBoostPlugin
()
@interface
FlutterBoostPlugin
()
@property
(
nonatomic
,
strong
)
id
<
FLBFlutterApplicationInterface
>
application
;
@property
(
nonatomic
,
strong
)
id
<
FLBFlutterApplicationInterface
>
application
;
@property
(
nonatomic
,
strong
)
id
<
FLBAbstractFactory
>
factory
;
@property
(
nonatomic
,
strong
)
FlutterMethodChannel
*
methodChannel
;
@property
(
nonatomic
,
strong
)
FlutterMethodChannel
*
methodChannel
;
@property
(
nonatomic
,
copy
)
NSString
*
fPageId
;
@property
(
nonatomic
,
copy
)
NSString
*
fPageId
;
@property
(
nonatomic
,
copy
)
NSString
*
fPagename
;
@property
(
nonatomic
,
copy
)
NSString
*
fPagename
;
...
...
ios/Classes/Engine/FLBFlutterEngine.m
View file @
ef1f8f2d
...
@@ -101,11 +101,6 @@
...
@@ -101,11 +101,6 @@
arguments:
nil
];
arguments:
nil
];
}
}
-
(
FlutterEngine
*
)
engine
{
return
_engine
;
}
-
(
void
)
atacheToViewController
:(
FlutterViewController
*
)
vc
-
(
void
)
atacheToViewController
:(
FlutterViewController
*
)
vc
{
{
if
(
_engine
.
viewController
!=
vc
){
if
(
_engine
.
viewController
!=
vc
){
...
@@ -128,5 +123,15 @@
...
@@ -128,5 +123,15 @@
// [self detach];
// [self detach];
}
}
-
(
void
)
dealloc
{
[
self
.
engine
setViewController
:
nil
];
[
self
.
engine
destroyContext
];
__weak
__typeof__
(
_engine
)
weak
=
_engine
;
NSLog
(
@"Retain count is %ld"
,
CFGetRetainCount
((
__bridge
CFTypeRef
)
weak
));
//// CFRelease((__bridge CFTypeRef)_engine);
// _engine = nil;
// NSLog(@"after Retain count is %ld", CFGetRetainCount((__bridge CFTypeRef)weak));
// NSLog(@"[DEBUG]---dealloc--");
}
@end
@end
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