当前位置:网站首页>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
边栏推荐
- Nestjs configuration service, configuring cookies and sessions
- Talk about the state management mechanism in Flink framework
- 并发编程-单例
- Slam mapping and autonomous navigation simulation based on turnlebot3
- (构造笔记)GRASP学习心得
- 小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
- Notes on 32-96 questions of sword finger offer
- vulnhub之pyexp
- Cacti监控Redis实现过程
- OpenGL 着色器使用
猜你喜欢
随机推荐
OpenGL 索引缓存对象EBO和线宽模式
rxjs Observable filter Operator 的实现原理介绍
vulnhub之presidential
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.".
PHP導出word方法(一mht)
Nestjs configuration service, configuring cookies and sessions
vulnhub之Ripper
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
XML (DTD, XML parsing, XML modeling)
previous permutation lintcode51
Groovy测试类 和 Junit测试
Niuniu's team competition
PHP Basics
Raven2 of vulnhub
STL教程9-容器元素深拷贝和浅拷贝问题
PHP get the file list and folder list under the folder
Hongmeng fourth training
Vulnhub geminiinc V2
Master and backup role election strategy in kept
Keepalived中Master和Backup角色选举策略








