Go to the project directory and add the following dependencies in pubspec.yaml
pubspec.yaml
...dependencies:leak_detector:git:url:https://gitcode.com/openharmony-sig/flutter_leak_detector.git# ref: 1.1.0-ohos.1.0.0-beta.1ref:TAG# Please select the TAG to the TAG Version Mapping ...
If the value of **ohos Support** is **yes**, it means that the ohos platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
LeakNavigatorObserver
Name
Description
Type
Input
Output
ohos Support
checkLeakDelay
Default delay time for leak detection
int
/
/
yes
shouldCheck
Callback to determine if route is added to detection
ShouldAddedRoute
Route route
bool
yes
didPop
Triggered when route is popped
function
Route route, Route? previousRoute
void
yes
didPush
Triggered when route is pushed
function
Route route, Route? previousRoute
void
yes
didRemove
Triggered when route is removed
function
Route route, Route? previousRoute
void
yes
didReplace
Triggered when route is replaced
function
{Route? newRoute, Route? oldRoute}
void
yes
LeakDetector
Name
Description
Type
Input
Output
ohos Support
maxRetainingPath
Limit for VmService.getRetainingPath
static int?
/
/
yes
onLeakedStream
Memory leak event stream
Stream
/
/
yes
onEventStream
Detection process event stream
Stream
/
/
yes
init
Initialize configuration
function
{int maxRetainingPath = 300}
void
yes
ensureReleaseAsync
Asynchronous release detection
function
String? group, {int delay = 0}
Future
yes
addWatchObject
Add monitored object
function
Object obj, String group
void
yes
StateLeakMixin
Name
Description
Type
Input
Output
ohos Support
checkLeakDelayMill
Get delay time in milliseconds
getter
/
int
yes
watchGroup
Get monitoring group identifier
getter
/
String
yes
initState
Initialization lifecycle method
function
/
void
yes
dispose
Destruction lifecycle method
function
/
void
yes
LeakPreviewPage
Name
Description
Type
Input
Output
ohos Support
leakInfoList
Stores leak information list
final List
/
/
yes
showLeakedInfoPage
Display single leak details
function
BuildContext context, LeakedInfo leakInfo
void
yes
showLeakedInfoListPage
Display leak information list
function
BuildContext context, List leakInfoList
void
yes
LeakedRecordStore
Name
Description
Type
Input
Output
ohos Support
getAll
Get all leak records
function
/
Future<List>
yes
clear
Clear storage
function
/
void
yes
deleteById
Delete record by ID
function
int id
void
yes
addAll
Batch add records
function
List list
void
yes
add
Add single record
function
LeakedInfo info
void
yes
LeakedInfo
Name
Description
Type
Input
Output
ohos Support
retainingPath
Reference chain path
List
/
/
yes
gcRootType
GC root type
String?
/
/
yes
timestamp
Detection timestamp
int?
/
/
yes
isNotEmpty
Check if reference chain is non-empty
getter
/
bool
yes
retainingPathJson
Convert reference chain to JSON string
getter
/
String
yes
4. Properties
If the value of **ohos Support** is **yes**, it means that the ohos platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.