当前位置:网站首页>Flutter: about monitoring on flutter applications
Flutter: about monitoring on flutter applications
2022-07-03 12:01:00 【J_ D_ Chi】
List of articles
Write it at the front
Yes Flutter Record some places that need relevant monitoring
Content
WidgetsBindingObserver
Mix in WidgetsBindingObserver
after , We can implement some monitoring .
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
@override
void initState() {
WidgetsBinding.instance.addObserver(this);
super.initState();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: Builder(
builder: (BuildContext context) {
return Center(
child: Column(
children: [
TextButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return SecondPage();
}));
},
child: Text("press")),
],
),
);
},
),
),
);
}
}
App Front and rear monitoring
stay didChangeAppLifecycleState()
in , We can monitor app In the running state of the front and rear platforms .
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print(state.toString());
super.didChangeAppLifecycleState(state);
}
When the home Key let app When you step back from the front desk to the backstage , give the result as follows :
flutter: AppLifecycleState.inactive
flutter: AppLifecycleState.paused
Then switch from the background to the foreground :
flutter: AppLifecycleState.inactive
flutter: AppLifecycleState.resumed
AppLifecycleState
AppLifecycleState
There are several States :
- resumed
- inactive
- paused
- detached
resumed
Express app It is visible and can respond to user input
inactive
Express app Is inactive and cannot respond to user input
iOS
stay iOS On , If there is a phone call 、Touch ID Request , Or sliding out the control bar will make it in inactive state .
Android
stay Android On , If there is a phone call 、 the other one Activity Got the focus ( For example, split screen app)、 Picture in picture app、 A system pop-up window, etc , Will make it in inactive state .
paused
This state means that the application cannot be seen by the user at this time , Unable to respond to user input , And it runs in the background .
In this state ,Flutter Engine Not invoke PlatformDispatcher.onBeginFrame
and PlatformDispatcher.onDrawFrame
Callback .
detached
In this state ,app Still will be Flutter Engine Held by , But not by any host View hold . That is to say, at this time Engine There is no View Operation in case of .
But at present, there should be some defects in callback , You can further view AppLifeCycleState.detached is not called when app is closed quickly #57594
边栏推荐
- 836. Merge sets (day 63) and search sets
- vulnhub之narak
- PHP导出word方法(一mht)
- Sheet1$. Output [excel source output] Error in column [xxx]. The returned column status is: "the text is truncated, or one or more characters have no matches in the target code page.".
- laravel 时区问题timezone
- Vulnhub's Nagini
- Concurrent programming - singleton
- Momentum of vulnhub
- Why can't my MySQL container start
- Web security summary
猜你喜欢
随机推荐
Groovy test class and JUnit test
Uniapp implementation Click to load more
Download address and installation tutorial of vs2015
Experience container in libvirt
Test classification in openstack
[learning notes] DP status and transfer
Php Export word method (One MHT)
Cacti监控Redis实现过程
为什么我的mysql容器启动不了呢
外插散点数据
Differences between MySQL Union and union all
Pragma pack syntax and usage
Sheet1$.输出[Excel 源输出].列[XXX] 出错。返回的列状态是:“文本被截断,或者一个或多个字符在目标代码页中没有匹配项。”。
Wrong arrangement (lottery, email)
MCDF实验1
抓包整理外篇fiddler———— 会话栏与过滤器[二]
解决msvcp120d.dll和msvcr120d.dll缺失
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
DEJA_VU3D - Cesium功能集 之 054-模拟火箭发射全过程
Yintai department store ignites the city's "night economy"