当前位置:网站首页>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
边栏推荐
猜你喜欢

Hongmeng fourth training

PHP Basics

Shardingsphere sub database and sub table < 3 >

STL教程9-容器元素深拷贝和浅拷贝问题

Vulnhub's Tomato (tomato)

Unity3d learning notes 5 - create sub mesh

XML (DTD, XML parsing, XML modeling)

Yintai department store ignites the city's "night economy"

网络通讯之Socket-Tcp(一)
![[official MySQL document] deadlock](/img/2d/04e97d696f20c2524701888ea9cd10.png)
[official MySQL document] deadlock
随机推荐
Vulnhub's presidential
ArcGIS application (XXI) ArcMap method of deleting layer specified features
How to convert a numeric string to an integer
优化接口性能
Hongmeng fourth training
XML (DTD, XML parsing, XML modeling)
Master and backup role election strategy in kept
Momentum of vulnhub
2022年湖南工学院ACM集训第二次周测题解
Socket TCP for network communication (I)
【mysql官方文档】死锁
Oracle advanced (I) realize DMP by expdp impdp command
MySQL searches and sorts out common methods according to time
STL tutorial 10 container commonalities and usage scenarios
DNS multi-point deployment IP anycast+bgp actual combat analysis
Xiaopeng P7 hit the guardrail and the airbag did not pop up. The official responded that the impact strength did not meet the ejection requirements
PHP export word method (phpword)
(数据库提权——Redis)Redis未授权访问漏洞总结
vulnhub之cereal
Keepalived中Master和Backup角色选举策略