Page full life cycle monitoring method, device, equipment and storage medium based on Flutter
By rewriting the component listener and navigation listener, monitoring the life cycle status of the Flutter page, solving the problem that the existing technology cannot monitor the page pause and recovery status, and achieving accurate monitoring and data acquisition of the entire life cycle of the page.
Patent Information
- Application Number
- CN202011221834.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-05
- Publication Date
- 2024-11-26
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing Flutter page component lifecycle method cannot effectively monitor the page in the pause and recovery state, resulting in the inability to accurately obtain page usage behavior data and cannot fully meet business needs.
By rewriting the application lifecycle state change method of component listener, the page is initialized, paused, restored and destroyed, and the navigation listener and page state abstract class are used to uniformly encapsulate judgment logic to obtain the full lifecycle state of the page.
It realizes effective monitoring of the entire life cycle of the page, accurately obtains page usage behavior data, and meets business needs.
Smart Images

Figure CN112463518B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for monitoring the entire life cycle of a page based on Flutter. Background Art
[0002] By analyzing the data obtained from user behavior monitoring, application providers can understand user behavior habits in more detail and clearly, thereby finding problems with application provider products or marketing such as websites, mobile applications, and promotion channels, which helps application providers develop products that better meet user needs and discover high-conversion rate pages. Therefore, user page usage data analysis is extremely important, that is, after obtaining basic data on platform visits such as website or APP pages, the relevant data is counted and analyzed to find out the rules of user visits to websites or APP platforms, and these rules are combined with product optimization strategies or online marketing strategies, so as to find out possible problems in current product design or online marketing activities, and provide a basis for further optimizing products or revising online marketing strategies.
[0003] Flutter is an open source UI toolkit from Google Inc. It is a cross-platform development framework that helps developers efficiently build beautiful multi-platform applications through a set of code bases, supporting mobile terminals (iOS, Android), Web, desktop and embedded platforms. As we all know, after a product is developed and delivered to users, in order to better collect user usage behavior and adjust and optimize the product, data statistics are needed. Among them, page behavior statistics are very important and the most basic, which obtains user page usage behavior data. The page usage behavior data includes the number of page visits, page access paths, page access duration, etc.
[0004] In the Flutter development framework, everything is a widget. If you want to count the above page behaviors, you can only do so in the page component StatefulWidget lifecycle method provided by the Flutter SDK. The page component lifecycle refers to the complete process of a page from creation to initialization, suspension, resumption, and destruction. The existing page component lifecycle methods include the state initialization method initState and the destruction method onDispose, which is recorded as page entry in the state initialization method and page exit in the destruction method.
[0005] The existing page usage behavior data statistics method, that is, the page component life cycle method, has the following shortcomings: First, the life cycle method provided by the Flutter framework only includes the initialization method initState and the destruction method onDispose. When the page is in the intermediate state such as pause and resume, there is no corresponding life cycle method for statistics, which leads to the inability to effectively monitor the entire life cycle of the page, which is not conducive to accurately obtaining page usage behavior data, and thus cannot fully meet business needs. Specifically, the user first enters the first-level page, at which time the state of the first-level page is called "initialization"; through a certain operation to enter the second-level page, the first-level page is not visible to the user but is not destroyed, at which time the state of the first-level page is called "pause"; when the user returns from the second-level page to the first-level page, the first-level page is visible to the user again, at which time the state of the first-level page is called "restore"; if the user then exits the first-level page through a certain operation, the state of the first-level page is called "destruction"; it can be seen that the entire life cycle of a page consists of 4 states.
[0006] Based on this, the technical problem to be solved by the present invention is: how to effectively monitor the entire life cycle of a page component, including initialization, suspension, resumption and destruction. Summary of the invention
[0007] In response to the above problems, the present invention provides a page full life cycle monitoring method, device, equipment and storage medium based on Flutter. The present invention supports full life cycle monitoring of Flutter page component initialization, suspension, resumption and destruction, and can effectively monitor the entire life cycle of the page, thereby facilitating accurate acquisition of page usage behavior data to fully meet business needs.
[0008] On the one hand, the present invention provides a page full life cycle monitoring method based on Flutter, and its technical solution is as follows:
[0009] A page life cycle monitoring method based on Flutter, wherein the page life cycle includes initialization state, pause state, resume state and destruction state, and is characterized by:
[0010] When the user returns to the system desktop or jumps to other applications, the application lifecycle state change method of the component listener is rewritten to obtain whether the current application is in the resumed or paused state for the user when the application state changes;
[0011] When a user operates a page, a corresponding page operation method is triggered. When the page operation method is invoked, at least one parameter is passed in. By obtaining the page indicated in the parameter, it is determined whether the page is in a paused state or a resumed state.
[0012] Furthermore, when the user opens the current page for the first time, the initialization method is triggered, and the current page is in the initialization state. When the user exits the current page, the destruction method is triggered, and the current page is in the destruction state.
[0013] Specifically, the page operations include opening a page, exiting a page, removing a page, and replacing a page.
[0014] Specifically, the page operation method includes a page opening method, an exit method, a removal method and a replacement method.
[0015] Specifically, the parameter is the previousRoute parameter.
[0016] Further, when the open method or the replace method is called, the page indicated by the parameter is the current page, and it is determined that the current page is about to enter a pause state.
[0017] Furthermore, when the exit method or the remove method is called, and the page indicated by the parameter is the current page, it is determined that the current page is about to enter a recovery state.
[0018] Specifically, the component listener is responsible for monitoring the pause state and resume state when switching between different applications.
[0019] Specifically, the navigation listener monitors the pause state and resume state of all page switches within the same application.
[0020] Furthermore, the judgment logic of the page full life cycle monitoring method is uniformly encapsulated in the page status abstract class.
[0021] On the other hand, a Flutter-based page full life cycle monitoring device is also provided, and the device includes:
[0022] The state monitoring module of the page when switching between applications is used to obtain whether the current application is in the resumed or paused state for the user by rewriting the application life cycle state change method of the component listener when the application state changes when the user returns to the system desktop or jumps to other applications;
[0023] The page status monitoring module when switching pages within the application is used to trigger the corresponding page operation method when the user operates the page. When the page operation method is invoked, at least one parameter is passed in; by obtaining the page indicated in the parameter, it is determined whether the page is in a paused state or a resumed state.
[0024] Furthermore, the device also includes:
[0025] The page initialization status and destruction status monitoring module is used to monitor the page initialization status and destruction status. When the user opens the current page for the first time, the initialization method will be triggered, and the current page is in the initialization state. When the user exits the current page, the destruction method will be triggered, and the current page is in the destruction state.
[0026] On the other hand, a Flutter-based page life cycle monitoring device is also provided, the device including a processor and a memory, the memory storing at least one instruction, at least one program, a code set, or an instruction set, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement any of the above-mentioned page life cycle monitoring methods.
[0027] On the other hand, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, code set or instruction set is stored, and the at least one instruction, at least one program, code set or instruction set is loaded by a processor and executed by any of the page life cycle monitoring methods described above.
[0028] The Flutter-based page full life cycle monitoring method, device, equipment, and storage medium provided in this application have the following technical effects:
[0029] The present invention provides a technical solution for how to monitor the entire life cycle of a page component, wherein the entire life cycle of the page component includes initialization, suspension, recovery, and destruction; by rewriting the application life cycle state change method of the component listener, when the application state changes, it is possible to obtain whether the current application is in a restored state or a suspended state for the user; when the user operates the page, the corresponding page operation method is triggered, and the page indicated in the incoming parameter is obtained to determine whether the page is in a suspended state or a restored state. The page life cycle monitoring solution based on the present invention can effectively monitor the entire life cycle of the page, thereby facilitating accurate acquisition of page usage behavior data to fully meet business needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a schematic diagram of a Flutter-based page full life cycle monitoring method provided by an embodiment of the present invention.
[0031] Figure 2 This is a schematic diagram of another Flutter-based page full life cycle monitoring method provided by an embodiment of the present invention.
[0032] Figure 3 This is a schematic diagram of a Flutter-based page full life cycle monitoring device provided by an embodiment of the present invention.
[0033] Figure 4This is a schematic diagram of another Flutter-based page full life cycle monitoring device provided in an embodiment of the present invention.
[0034] Figure 5 It is a workflow diagram provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0035] In order to enable those skilled in the art to better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only an embodiment of a part of the present invention, not all of the embodiments, and this embodiment is only used to explain the present invention and does not constitute a limitation on the scope of protection of the present invention. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative work should fall within the scope of protection of this application.
[0036] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0037] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.
[0038] Those skilled in the art can understand that the terms "page", "application", "page access", "page component life cycle" and the like used herein are applicable to mobile terminals or Web or desktop or embedded platforms, and the "application" can be application software or system software. The "device" described in the present invention may include: computers, tablet computers, mobile phones, wearable devices (such as bracelets, etc.), and the like.
[0039] First, the technical terms that may be involved in the present invention are briefly described:
[0040] Flutter: It is an open source UI toolkit from Google Inc. and a cross-platform development framework that helps developers efficiently build exquisite multi-platform applications through a set of code bases. It supports mobile (iOS, Android), Web, desktop and embedded platforms.
[0041] Page component life cycle: refers to the complete process of a page from creation to initialization, suspension, resumption, and destruction.
[0042] After a product is developed and delivered to the user, data statistics are needed to better collect user behavior and adjust and optimize the product. Among them, the most important and basic is page behavior statistics, including page visit counts, page visit paths, page visit duration, etc.
[0043] In the Flutter development framework, everything is a widget. If you want to count the above page behaviors, you can only do so in the StatefulWidget lifecycle method of the page component provided by the Flutter SDK, including the state initialization method initState and the destruction method onDispose, that is, the state initialization method is recorded as page entry, and the destruction method is recorded as page exit.
[0044] The present invention relates to a component listener WidgetsBindingObserver, a navigation listener GlobalNavigatorObserver, and a page state abstract class BasePageState <textendsstatefulwidget>, page life cycle global listener BasePageStateObservable these four functional modules.
[0045] The following describes a specific embodiment of the method for monitoring the entire life cycle of a page based on Flutter of the present invention. Figure 1 A schematic diagram of a method for monitoring the entire life cycle of a page based on Flutter is provided in this embodiment. The present invention provides method operation steps as described in this embodiment or flowchart, but more or fewer operation steps may be included based on conventional or non-creative labor. The sequence of steps listed in the embodiment is only one way of executing the sequence of many steps and does not represent the only execution sequence. The execution subject of the method may be a terminal, and the terminal may specifically include software running in a physical device, such as an application installed on the device, etc., and may also include at least one of the physical devices of the type of a smartphone, a tablet computer, a digital assistant, a smart wearable device, etc., with an application installed. Specifically, an operating system runs on the terminal, and the operating system may be an iOS (Apple mobile terminal operating system) or an Android operating system or other operating systems.
[0046] Embodiment 1 of the present invention, as Figure 1 The specific implementation of the method for monitoring the entire life cycle of a page based on Flutter is as follows:
[0047] The full life cycle of the page described in the present invention includes an initialization state, a pause state, a resume state, and a destruction state.
[0048] S01: When the user returns to the system desktop or jumps to other applications, the application life cycle state change method of the component listener is rewritten to obtain whether the current application is in the resumed state or the paused state for the user when the application state changes.
[0049] It should be noted here that the pause and resume states when switching between applications are realized by monitoring the states of different applications through the component listener WidgetsBindingObserver. That is, when the user returns to the system desktop or jumps to other applications, the application lifecycle state change method didChangeAppLifecycleState of the component listener will be triggered. By overriding this method, it is possible to obtain in real time whether the current application is resumed (application visible) or paused (application invisible) to the user when the application state changes.
[0050] Specifically, if the application state changes from the resume state (visible state) to the pause state, such as pressing the Home button to return to the desktop or switch to other applications, then the top-level page of the application also becomes the pause state accordingly; if the application state changes from the pause state to the resume state (visible state), such as clicking the application icon from the desktop to open the application again or switching back to the application from other applications, then the top-level page of the application also becomes the resume state (visible state) accordingly.
[0051] S02: When a user operates a page, a corresponding page operation method is triggered. When the page operation method is invoked, at least one parameter is passed in. By obtaining the page indicated in the parameter, it is determined whether the page is in a paused state or a resumed state.
[0052] It should be noted here that the pause and resume states of page switching are achieved by globally monitoring all page switching events in the application through the navigation listener GlobalNavigatorObserver. That is, when the user opens a page, exits a page, removes a page, or replaces a page, the corresponding opening method didPush, exit method didPop, removal method didRemove, and replacement method didReplace will be triggered.
[0053] As can be seen from these method signatures, when the Flutter framework invokes these methods, it will pass in route (Route <dynamic>Type) and previousRoute(Route <dynamic>Type), the present invention determines whether the page is in a paused or resumed state by obtaining the page indicated in the previousRoute parameter.
[0054] Specifically: when the opening method didPush and the replacement method didReplace are called, if the page indicated by the parameter previousRoute is the current page, then the current page is about to enter the pause state; when the exit method didPop and the removal method didRemove are called, if the page indicated by the parameter previousRoute is the current page, then the current page is about to enter the resume state.
[0055] Embodiment 2 of the present invention, as Figure 2 Compared with the above-mentioned embodiment 1, the difference between the second embodiment and the first embodiment is that it further includes S00 and S03.
[0056] S00: When the user opens the current page for the first time, the initialization method will be triggered, and the current page is in the initialization state.
[0057] It should be noted here that the page state abstract class BasePageState<T extends StatefulWidget> It is the parent class of all page components. The present invention uses the page state abstract class BasePageState<T extendsStatefulWidget> To implement page initialization. When the user opens the current page for the first time, the initialization method initState will be triggered, and the current page is in the initialization state.
[0058] S03: When the user exits the current page, the destruction method will be triggered, and the current page is in a destroyed state.
[0059] Similarly, the present invention uses the page state abstract class BasePageState<T extends StatefulWidget> To achieve the page destruction state. When the user exits the current page, the destruction method dispose will be triggered, and the current page is in the destroyed state.
[0060] The judgment logic of the page life cycle monitoring method described in the first and second embodiments of the present invention is uniformly encapsulated in the page state abstract class, so that developers do not need to care about the internal implementation logic, which can greatly reduce the developer's work. We also stipulate that all page states must inherit from the page state abstract class.
[0061] In addition, the page lifecycle global listener BasePageStateObservable provides a globally unique page component lifecycle monitoring outlet within the application, where statistical data can be uploaded.
[0062] The listener provides four interface methods: page entry method onInitState(State state), page pause method onPause(State state), page recovery method onResume(State state), and page destruction method onDispose(State state). The developer needs to pass the page state abstract class BasePageState into the listener instance object.
[0063] When the page life cycle changes, the page state abstract class BasePageState calls the four methods corresponding to the instance object, which is the interface callback. Developers can obtain the page name indicated by the parameter state (state.widget.toString) in these four interface methods to upload statistical data without writing cumbersome embedding code.
[0064] The overall workflow of the present invention involves component listener WidgetsBindingObserver, navigation listener GlobalNavigatorObserver, page state abstract class BasePageState<Textends StatefulWidget> , the page life cycle global listener BasePageStateObservable, the method flow of the above four parts is as follows Figure 5 shown.
[0065] Open the application, the Flutter framework starts, executes the runApp method of the application, and returns the material application component MaterialApp to the Flutter framework.
[0066] Pass the global navigation listener GlobalNavigatorObserver instance object to the navigation listener construction parameter navigatorObservers of the material application component MaterialApp to start monitoring the switching events of all pages in the application.
[0067] Generate a page lifecycle global listener and generate a BasePageStateObservable instance object for the page lifecycle global listener, and pass it to the page state abstract class BasePageState.
[0068] Enter the page and trigger the corresponding page entry method onInitState (for clear description, recorded as "page entry method A"). In this method, call the addObserver method of the component binding class WidgetsBinding provided by the Flutter architecture to pass in the component listener WidgetsBindingObserver instance object to start application status monitoring.
[0069] At the same time, the page entry method onInitState(State state) of the page life cycle global listener BasePageStateObservable instance object is triggered in the page entry onInitState method (for clear description, recorded as "page entry method B").
[0070] Subsequent page pauses, resumes, and destructions caused by page switching and application switching will trigger the page pause method onPause(State state), page resume method onResume(State state), and page destruction method onDispose(State state) of the lifecycle global listener BasePageStateObservable instance object.
[0071] In the corresponding method of the BasePageStateObservable instance object of the lifecycle global listener, upload statistical data.
[0072] The statistical background is used for data analysis and display.
[0073] Embodiment 3 of the present invention is an embodiment of the device of the present invention, such as Figure 3 As shown, it can be used to execute the method embodiment of the present invention. For details not disclosed in the device embodiment of the present invention, please refer to the method embodiment of the present application.
[0074] Please refer to Figure 3 , which shows a structural block diagram of a Flutter-based page full life cycle device provided by an embodiment of the present invention. The device D1 may include:
[0075] Page status monitoring module M01 when switching between applications: When the user returns to the system desktop or jumps to other applications, it rewrites the application lifecycle state change method of the component listener to obtain whether the current application is in the resumed or paused state for the user when the application state changes.
[0076] This embodiment realizes the pause and resume state when switching between applications by monitoring the state of different applications through the state monitoring module M01 of the page when switching between applications. That is, when the user returns to the system desktop or jumps to other applications, the application life cycle state change method didChangeAppLifecycleState of the component listener will be triggered. By rewriting this method, it is possible to obtain in real time whether the current application is restored (application visible) or paused (application invisible) to the user when the application state changes. Specifically, if the application state changes from the restored state (visible state) to the pause state, such as pressing the Home button to return to the desktop or switch to other applications, then correspondingly, the top-level page of the application also becomes the pause state; if the application state changes from the pause state to the restored state (visible state), such as clicking the application icon from the desktop to open the application again or switching back to the application from other applications, then correspondingly, the top-level page of the application also becomes the restored state (visible state).
[0077] The page status monitoring module M02 when switching pages within the application: is used to trigger the corresponding page operation method when the user operates the page, and at least one parameter is passed in when the page operation method is invoked; by obtaining the page indicated in the parameter, it is determined whether the page is in a paused state or a resumed state.
[0078] In this embodiment, the page status monitoring module M02 monitors all page switching events in the application globally to achieve the pause and resume state when the page switches. That is, when the user opens a page, exits a page, removes a page, or replaces a page, the corresponding opening method didPush, exit method didPop, removal method didRemove, and replacement method didReplace will be triggered. It can be seen from the signatures of these methods that when the Flutter framework invokes these methods, it will pass in route (Route <dynamic>Type) and previousRoute(Route <dynamic>Type), this embodiment determines whether the page is in the paused or resumed state by obtaining the page indicated by the previousRoute parameter. Specifically, when the opening method didPush and the replacement method didReplace are called, if the page indicated by the parameter previousRoute is the current page, then the current page is about to enter the paused state; when the exit method didPop and the removal method didRemove are called, if the page indicated by the parameter previousRoute is the current page, then the current page is about to enter the resumed state.
[0079] Embodiment 4 of the present invention is another embodiment of the device of the present invention. Figure 4 As shown, it can be used to execute the method embodiment of the present invention. For details not disclosed in the device embodiment of the present invention, please refer to the method embodiment of the present application.
[0080] Please refer to Figure 4 , which shows a structural block diagram of another Flutter-based page full life cycle device provided by an embodiment of the present invention. Compared with the device D1 described in the third embodiment, the device D2 described in this embodiment may also include:
[0081] Page initialization status and destruction status monitoring module M03: used to monitor the page initialization status and destruction status. When the user opens the current page for the first time, the initialization method will be triggered, and the current page is in the initialization state. When the user exits the current page, the destruction method will be triggered, and the current page is in the destruction state.
[0082] This embodiment implements page initialization through the page initialization state and destruction state monitoring module M03. When the user opens the current page for the first time, the initialization method initState will be triggered, and the current page is in the initialization state. Similarly, this embodiment implements the page destruction state through the page initialization state and destruction state monitoring module M03. When the user exits the current page, the destruction method dispose will be triggered, and the current page is in the destruction state.
[0083] Embodiment 5 of the present invention provides a page life cycle monitoring device based on Flutter, which may include a processor and a memory, in which at least one instruction, at least one program, a code set, or an instruction set is stored. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the page life cycle monitoring method based on Flutter provided in Embodiment 1 or Embodiment 2 of the above method.
[0084] Embodiment 6 of the present invention also provides a computer-readable storage medium, wherein at least one instruction, at least one program, code set, or instruction set is stored in the storage medium, and the at least one instruction, at least one program, code set, or instruction set is loaded by a processor and executed by any of the above-mentioned Flutter-based page life cycle monitoring methods.
[0085] Optionally, in an embodiment of the present application, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0086] The present invention provides a technical solution for how to monitor the entire life cycle of a page component, wherein the entire life cycle of the page component includes initialization, suspension, recovery, and destruction; by rewriting the application life cycle state change method of the component listener, when the application state changes, it is possible to obtain whether the current application is in a restored state or a suspended state for the user; when the user operates the page, the corresponding page operation method is triggered, and the page indicated in the incoming parameter is obtained to determine whether the page is in a suspended state or a restored state. The page life cycle monitoring solution based on the present invention can effectively monitor the entire life cycle of the page, thereby facilitating accurate acquisition of page usage behavior data to fully meet business needs.
[0087] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of this specification are described. Other embodiments are within the scope of the attached claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0088] The same or similar parts between the various embodiments in this specification can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0089] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or may be accomplished by instructing the relevant hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0090] The basic principles, main features and advantages of the present invention are shown and described above. Those skilled in the art should understand that the above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiment. The above embodiment and the description are only to illustrate the principle of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements fall within the scope of the present invention claimed for protection. The scope of protection claimed by the present invention is defined by the attached claims and their equivalents.< / dynamic> < / dynamic> < / dynamic> < / dynamic> < / textendsstatefulwidget>
Claims
1. A page lifecycle monitoring method based on Flutter, which includes initialization, pause, resume, and destruction states, is characterized by: When the user returns to the system desktop or jumps to another application, the component listener's application lifecycle state change method didChangeAppLifecycleState will be triggered. By overriding the component listener's application lifecycle state change method, you can obtain whether the current application is in the resumed or paused state for the user when the application state changes; The component listener is responsible for monitoring the pause and resume states when switching between different applications; The navigation listener monitors the pause and resume status of all page switches within the same application; When a user operates a page, a corresponding page operation method is triggered. The page operations include opening a page, exiting a page, removing a page, and replacing a page. The page operation methods include page opening method, exiting method, removing method, and replacing method. When the page operation method is invoked, at least one parameter is passed in, which is the previousRoute parameter. By obtaining the page indicated by the parameter, it is determined whether the page is in a paused state or a resumed state. When the open method or the replace method is called, and the page indicated by the parameter is the current page, it is determined that the current page is about to enter the pause state; when the exit method or the remove method is called, and the page indicated by the parameter is the current page, it is determined that the current page is about to enter the resume state; Method flow: Open the app, the Flutter framework starts, executes the runApp method, and returns the MaterialApp component to the Flutter framework. Pass the global navigation listener GlobalNavigatorObserver instance object to the navigation listener construction parameter navigatorObservers of the MaterialApp component to start monitoring the switching events of all pages in the application; Generate a BasePageStateObservable instance object of the page life cycle global listener and pass it to the page state abstract class BasePageState; Enter the page and trigger the corresponding page entry method onInitState. In this method, call the addObserver method of the component binding class WidgetsBinding provided by the Flutter architecture to pass in the component listener WidgetsBindingObserver instance object to start application status monitoring; At the same time, the page entry method onInitState of the page life cycle global listener BasePageStateObservable instance object is triggered in the page entry onInitState method; Subsequent page pauses, resumes, and destructions caused by page switching and application switching will trigger the page pause method onPause, page resume method onResume, and page destruction method onDispose of the lifecycle global listener BasePageStateObservable instance object; In the corresponding method of the BasePageStateObservable instance object of the lifecycle global listener, statistical data is uploaded and the statistical background performs data analysis and display.
2. The Flutter-based page full lifecycle monitoring method according to claim 1 is characterized in that: When the user opens the current page for the first time, the initialization method is triggered, and the current page is in the initialization state. When the user exits the current page, the destruction method is triggered, and the current page is in the destruction state.
3. The Flutter-based page full lifecycle monitoring method according to any one of claims 1 to 2 is characterized in that: The judgment logic of the page full life cycle monitoring method is uniformly encapsulated in the page status abstract class.
4. The page full life cycle monitoring device based on Flutter is characterized by: The method for monitoring the entire life cycle of a page based on Flutter according to any one of claims 1 to 3 includes: The state monitoring module for the page when switching between applications is used to obtain whether the current application is in the resumed or paused state for the user by overriding the application lifecycle state change method of the component listener when the application state changes. The page status monitoring module when switching pages within the application is used to trigger the corresponding page operation method when the user operates the page. When the page operation method is invoked, at least one parameter is passed in; by obtaining the page indicated in the parameter, it is determined whether the page is in a paused state or a resumed state.
5. The Flutter-based page full life cycle monitoring device according to claim 4 is characterized in that: Also includes: The page initialization status and destruction status monitoring module is used to monitor the page initialization status and destruction status. When the user opens the current page for the first time, the initialization method will be triggered, and the current page is in the initialization state. When the user exits the current page, the destruction method will be triggered, and the current page is in the destruction state.
6. The device for monitoring the entire life cycle of a page based on Flutter is characterized by: The device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the page full life cycle monitoring method as described in any one of claims 1 to 3.
7. A computer-readable storage medium, characterized in that The storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor according to any one of claims 1 to 3 as the page full life cycle monitoring method.
