Data transmission method and device between native platform and flutter platform and storage medium
By registering methods and sending identifiers on the Flutter web interface, an adapted message channel is established between the native platform and the Flutter container, solving the problem that developers need to remember message channel identifiers and enabling convenient data transmission.
Patent Information
- Application Number
- CN202210300626.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-24
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-03-24
AI Technical Summary
In data transfer between the native platform and the Flutter platform, developers need to manually remember the identifiers of the message channels, which is inconvenient to use.
Register a method to retrieve data on the Flutter web client and send the method name and the Flutter container identifier to the native platform. Establish an adapted message channel based on the Flutter container identifier to achieve the binding between the native platform and the Flutter container.
It eliminates the need for developers to remember message channel identifiers, enabling data transfer between the native platform and the Flutter platform, and the data transfer types have broad applicability.
Smart Images

Figure CN114647519B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The embodiment of the application relates to the Flutter technical field, and more particularly to a data transmission method and device between a native platform and a Flutter platform and a storage medium. BACKGROUND
[0002] Flutter is a mobile user interface (UI) framework, which contains a software development kit (SDK) for building cross-platform mobile app, and can quickly build high-quality user interfaces on native platforms (such as Android and iOS systems). At present, most developers expand Flutter functions in the current existing native platform to design user interfaces and business components, instead of completely Flutterizing the existing mobile app. That is, most of the current Flutter-based business componentization schemes are hybrid development modes of native engineering and Flutter engineering. The implementation mode of the hybrid development mode usually includes: introducing Flutter functions in the existing native platform development, taking the system engineering of the native platform as the main engineering, introducing the Flutter function module in the form of a sub-module (module), so that the existing native engineering has Flutter functions, and thus the various businesses of the native engineering can be developed and designed based on Flutter.
[0003] At present, when the native platform needs to send data to the Flutter container, the native platform establishes a message channel with the Flutter platform. The developer artificially remembers the identifier of the message channel, and then the developer binds the message channel with the Flutter container by using the identifier in the Flutter platform. Then, the native platform can send data to the Flutter container through the message channel. However, in this implementation mode, the developer needs to artificially remember the identifier of the message channel, which causes inconvenience for the developer. SUMMARY
[0004] The embodiment of the application provides a data transmission method and device between a native platform and a Flutter platform and a storage medium.
[0005] The technical scheme of the embodiment of the application is as follows:
[0006] A data transmission method between a native platform and a Flutter platform, comprising:
[0007] In a Flutter web page containing a Flutter container, a method for obtaining data for the Flutter container is registered;
[0008] In the Flutter web terminal, a method name of the method and an identifier of the Flutter container are sent to a native platform;
[0009] In the native platform, a message channel between the native platform and the Flutter container, which is adapted to the method name, is established based on the identifier of the Flutter container and the method name;
[0010] Data is transmitted between the native platform and the Flutter container based on the message channel.
[0011] In an exemplary embodiment, further comprising:
[0012] In the native platform, the identifier of the Flutter container and attribute parameters of the Flutter container are set; in the native platform, the Flutter container is created based on the identifier of the Flutter container and the attribute parameters of the Flutter container; in the native platform, a pop-up instruction is sent to the Flutter web terminal based on an event channel between the native platform and the Flutter web terminal, the pop-up instruction being used to instruct to pop up the Flutter container; in the Flutter web terminal, the Flutter container is popped up based on the pop-up instruction.
[0013] In an exemplary embodiment, the sending of the method name and the identifier of the Flutter container to the native platform comprises:
[0014] The method name and the identifier of the Flutter container are sent to the native platform based on a Flutter Plugin mode.
[0015] In an exemplary embodiment, the transmitting of data between the native platform and the Flutter container based on the message channel comprises:
[0016] When a calling command containing the method name is retrieved in a business code of the native platform, an identifier of a target Flutter container, which is a data receiving object, is obtained from the calling command;
[0017] Based on the identifier of the target Flutter container, a message channel between the native platform and the target Flutter container is determined;
[0018] Based on the message channel between the native platform and the target Flutter container, at least one of the following data is sent from the native platform to the target Flutter container:
[0019] Data originating from the native platform; data originating from the cloud.
[0020] An apparatus for data transmission between a native platform and a Flutter platform, comprising:
[0021] A registration module configured to register, at a Flutter web page comprising a Flutter container, a method for obtaining data for the Flutter container;
[0022] A sending module configured to send, at the Flutter web page, a method name of the method and an identifier of the Flutter container to a native platform;
[0023] An establishing module configured to establish, at the native platform, a message channel between the native platform and the Flutter container, which is adapted to be invoked by the method name, based on the identifier of the Flutter container;
[0024] A transmission module configured to transmit data between the native platform and the Flutter container based on the message channel.
[0025] In an exemplary embodiment, further comprising:
[0026] A pop-up module configured to set, at the native platform, the identifier of the Flutter container and attribute parameters of the Flutter container; create, at the native platform, the Flutter container based on the identifier of the Flutter container and the attribute parameters of the Flutter container; send, at the native platform, a pop-up instruction to the Flutter web page based on an event channel between the native platform and the Flutter web page, the pop-up instruction being used to instruct to pop up the Flutter container; and pop up, at the Flutter web page, the Flutter container based on the pop-up instruction.
[0027] In an exemplary embodiment, the sending module is configured to send the method name and the identifier of the Flutter container to the native platform based on a Flutter Plugin manner.
[0028] In an exemplary embodiment, the transmission module is configured to, when an invocation command containing the method name is retrieved in the service code of the native platform, acquire the identification of the target Flutter container as a data receiving object from the invocation command; determine a message channel between the native platform and the target Flutter container based on the identification of the target Flutter container; and send at least one of the following data from the native platform to the target Flutter container based on the message channel between the native platform and the target Flutter container: data originating from the native platform; data originating from the cloud.
[0029] A computer readable storage medium having stored thereon computer instructions, which, when executed by a processor, implement the steps of the data transmission method between the native platform and the Flutter platform as claimed in any one of the above.
[0030] An electronic device, comprising:
[0031] a processor;
[0032] a memory for storing executable instructions of the processor;
[0033] the processor is configured to read the executable instructions from the memory and execute the instructions to implement the data transmission method between the native platform and the Flutter platform as claimed in any one of the above.
[0034] A computer program product comprising computer instructions, which, when executed by a processor, implement the data transmission method between the native platform and the Flutter platform as claimed in any one of the above.
[0035] As can be seen from the above technical solutions, in the embodiments of the present application, a method for acquiring data for a Flutter container is registered in a Flutter web page end containing the Flutter container; in the Flutter web page end, the method name of the method and the identification of the Flutter container are sent to the native platform; in the native platform, based on the identification of the Flutter container, a message channel between the native platform and the Flutter container that is adapted to be invoked by the method name is established; and based on the message channel, data is transmitted between the native platform and the Flutter container. As can be seen, in the embodiments of the present application, the native platform establishes a message channel between the Flutter container corresponding to the identification that can be invoked by the method name based on the identification of the Flutter container, that is, the binding of the message channel and the Flutter container is implemented, so that the developer does not need to remember the identification of the message channel, and the data transmission between the native platform and the Flutter platform is implemented.
[0036] Moreover, in the embodiment of the present application, by applying the calling command containing the method name in the business code of the native platform, the data can be conveniently sent to the target Flutter container. Moreover, the data type sent to the target Flutter container has various embodiments, and has wide applicability. BRIEF DESCRIPTION OF DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0038] Figure 1 is a flowchart of the data transmission method between the native platform and the Flutter platform in the embodiment of the present application.
[0039] Figure 2 is an exemplary flowchart of the data transmission process between the native platform and the Flutter platform in the embodiment of the present application.
[0040] Figure 3 is an exemplary structural diagram of the data transmission device between the native platform and the Flutter platform in the embodiment of the present application.
[0041] Figure 4 is an exemplary structural diagram of the electronic device in the embodiment of the present application. DETAILED DESCRIPTION
[0042] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings.
[0043] In order to describe concisely and intuitively, the solutions of the present application will be described below by describing several representative embodiments. A large number of details in the embodiments are only used to help understand the solutions of the present application. However, it is obvious that the technical solutions of the present application can not be limited to these details. In order to avoid unnecessary obscuring of the solutions of the present application, some embodiments are not described in detail, but only a framework is given. In the following, “comprising” means “comprising but not limited to”, and “according to” means “at least according to, but not limited to only according to”. Due to the language habit of Chinese, when the quantity of a component is not specially indicated, it means that the component can be one or more, or can be understood as at least one.
[0044] With reference to the drawings, the technical solutions in the embodiments of the present application will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0045] The terms “first”, “second”, “third”, “fourth” and the like (if any) in the description and claims of the embodiments of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented, for example, in an order other than that illustrated or described herein.
[0046] In view of the defect in the prior art that a developer needs to artificially remember the message channel identifier to bind the message channel with the Flutter container, the Flutter web page of the embodiments of the present application sends the method name of data acquisition and the identifier of the Flutter container to the native platform, and the native platform establishes a message channel that can be called by the method name and corresponds to the Flutter container based on the identifier of the Flutter container, that is, the binding of the message channel and the Flutter container is realized, so that the developer does not need to remember the identifier of the message channel, and the data transmission between the native platform and the Flutter platform can be realized.
[0047] Figure 1 is a flowchart of the data transmission method between the native platform and the Flutter platform of the embodiments of the present application.
[0048] As shown in Figure 1 , the method comprises:
[0049] Step 101: In the Flutter web page containing the Flutter container, register a method (method) for acquiring data for the Flutter container.
[0050] Here, the method for acquiring data for the Flutter container in the Flutter web page is registered in the Flutter web page. The method is a function that can be called by an object, and can be implemented as a statement block containing a specific function.
[0051] For example, a method ReceiveMsg() with a method name ReceiveMsg is registered in the Flutter web end. The method ReceiveMsg() is used to obtain data for the Flutter container in the Flutter web end. In the registration process of the method ReceiveMsg(), the input variable, processing logic and return value of the method can be defined. The input variable declares the input value of the processing logic, and the return value contains the output value of the processing logic.
[0052] In the calling command for the registered method ReceiveMsg(), the method name ReceiveMsg and the specific value of the input variable are usually included. When the calling command is received in the native platform, it is determined that the method to be called is ReceiveMsg() based on the method name ReceiveMsg in the calling command, and the specific value of the input variable included in the calling command is assigned to the input variable in the method ReceiveMsg(). After the method ReceiveMsg() is assigned, the processing logic is executed, and the return value obtained by executing the processing logic is output.
[0053] In the registration process of the method ReceiveMsg(), a target variable for indicating a data receiving object can also be defined in the input variable, so as to indicate the receiving object of the return value by using the target variable. When the calling command is received in the native platform, the identifier of the target Flutter container included in the calling command is assigned to the target variable as the specific value of the target variable, so as to indicate that the return value of the method ReceiveMsg() is sent to the target Flutter container.
[0054] The above exemplary describes a typical example of registering a method for obtaining data in the Flutter web end. It can be understood by those skilled in the art that this method is only exemplary and does not limit the protection scope of the embodiments of the present application.
[0055] Step 102: In the Flutter web end, the method name of the method and the identifier of the Flutter container are sent to the native platform.
[0056] Here, the method name and the identifier of the Flutter container that needs to receive data based on the method name are sent to the native platform based on the Flutter Plugin method. For example, in the Flutter Plugin method, the method name and the identifier of the Flutter container can be sent to the native platform through a platform channel.
[0057] It can be seen that the method name and the identifier of the Flutter container are sent to the native platform in a Flutter Plugin manner.
[0058] For example, when the method ReceiveMsg() is registered, it is assumed that the number of Flutter containers that need to use the registered method to obtain data is one, and the identifier of the Flutter container is ABC. The Flutter webpage sends the identifier ABC and the method name ReceiveMsg to the native platform.
[0059] For another example, when the method ReceiveMsg() is registered, it is assumed that the number of Flutter containers that need to use the registered method to obtain data is two, and the identifiers of the two Flutter containers are ABC and DEF. The identifier ABC, the identifier DEF and the method name ReceiveMsg are sent to the native platform.
[0060] Here, the native platform can be implemented as an Android platform or an iOS platform, and the embodiments of the present application are not limited thereto.
[0061] Step 103: In the native platform, a message channel between the native platform and the Flutter container that is adapted to be called by the method name is established based on the identifier of the Flutter container.
[0062] Here, after the native platform obtains the method name and the identifier of the Flutter container, the specific Flutter container is first determined based on the identifier of the Flutter container, and then the message channel between the native platform and the Flutter container that is adapted to be called by the method name is established.
[0063] In step 103, the message channel between the native platform and the Flutter container can be established. The number of Flutter containers in the Flutter webpage can be multiple, and the number of corresponding message channels can also be multiple. Multiple message channels can be called by a common method name.
[0064] For example, when the native platform receives the identifier ABC and the method name ReceiveMsg, a message channel between the native platform and the Flutter container ABC that is adapted to be called by the method name ReceiveMsg is established in step 103.
[0065] For example, when the native platform receives the identifier ABC, the identifier DEF, and the method name ReceiveMsg, the first message channel between the native platform and the Flutter container ABC that is invoked by the method name ReceiveMsg is established in step 103, and the second message channel between the native platform and the Flutter container DEF that is invoked by the method name ReceiveMsg is established. It can be seen that the first message channel contains the binding relationship between the native platform and the Flutter container ABC, and the second message channel contains the binding relationship between the native platform and the Flutter container DEF. Therefore, the developer does not need to remember the identifier of the message channel, and the binding between the native platform and the Flutter container can be achieved.
[0066] Step 104: transmitting data between the native platform and the Flutter container based on the message channel.
[0067] It can be seen that in the embodiment of the application, the native platform establishes a message channel with the Flutter container that can be invoked by the method name based on the identifier of the Flutter container, and the binding between the message channel and the Flutter container is achieved, so that the developer does not need to remember the identifier of the message channel, and the data transmission between the native platform and the Flutter platform can be achieved.
[0068] In an exemplary embodiment, when the calling command containing the method name is retrieved in the business code of the native platform, the identifier of the target Flutter container that is the data receiving object is obtained from the calling command; based on the identifier of the target Flutter container, the message channel between the native platform and the target Flutter container is determined; and based on the message channel between the native platform and the target Flutter container, data is sent from the native platform to the target Flutter container. The data sent can be data originating from the native platform or data originating from the cloud.
[0069] It can be seen that in the embodiment of the application, the calling command containing the method name is applied in the business code of the native platform, and data can be conveniently sent to the target Flutter container. Moreover, the type of data sent to the target Flutter container has various embodiments and has wide applicability.
[0070] Moreover, in the embodiment of the application, the Flutter container can also send data to the native platform based on the message channel.
[0071] In an embodiment, the method further comprises: setting, at the native platform, an identifier of the Flutter container and attribute parameters of the Flutter container; creating, at the native platform, the Flutter container based on the identifier of the Flutter container and the attribute parameters of the Flutter container; sending, at the native platform, a pop-up instruction to the Flutter web end based on an event channel between the Flutter web end and the native platform, the pop-up instruction being used to instruct to pop up the Flutter container; and popping up, at the Flutter web end, the Flutter container based on the pop-up instruction. The attribute parameters of the Flutter container can include a container width, a container height, a container alignment attribute, a container color attribute, and a sub-component of the container, etc. In the process of creating the container at the native platform, the attributes of the created container are set according to the attribute parameters, and the identifier of the created container is assigned as the set identifier.
[0072] It can be seen that, by popping up the Flutter container created by the native platform at the Flutter web end, the Flutter container is facilitated to perform subsequent processing such as display and secondary development on the data received from the native platform.
[0073] Figure 2 is an exemplary flowchart of a data transmission process between the native platform and the Flutter platform of an embodiment of the present application.
[0074] As shown in Figure 2 , the method comprises:
[0075] Step 201: The native platform creates a Flutter container.
[0076] For example, the native platform can create a first Flutter container based on attribute parameters of the first Flutter container and an identifier of the first Flutter container, create a second Flutter container based on attribute parameters of the second Flutter container and an identifier of the second Flutter container, and create a third Flutter container based on attribute parameters of the third Flutter container and an identifier of the third Flutter container. The attribute parameters of the first Flutter container, the identifier of the first Flutter container, the attribute parameters of the second Flutter container, the identifier of the second Flutter container, the attribute parameters of the third Flutter container, and the identifier of the third Flutter container can all be manually set by a developer or automatically set by a machine according to predetermined rules.
[0077] Step 202: The native platform pops up the Flutter container in the Flutter web end.
[0078] Continuing the previous example, the native platform sends a pop-up instruction to the Flutter web end based on the event channel between the native platform and the Flutter web end. The pop-up instruction is used to indicate that the first Flutter container, the second Flutter container, and the third Flutter container are popped up in the Flutter web end.
[0079] Step 203: In the Flutter web end, a method for obtaining data is registered.
[0080] For example, the native platform registers a method ReceiveMsg() for obtaining data in the Flutter web end. The registration process includes defining the input variable, processing logic, and return value of the method. Among them: the input variable declares the input value of the processing logic; the return value contains the output value of the processing logic. For example, the input variable can include: (1) a target variable indicating an object receiving the return value; (2) a current power variable of the device; the processing logic can include: an operation rule for calculating the standby time based on the current power variable of the device; the return value can include: the standby time.
[0081] Step 204: In the Flutter web end, read the identifier of the Flutter container that expects to receive data from the native platform.
[0082] Continuing the previous example, assuming that the developer sets the first Flutter container and the second Flutter container to receive data from the native platform, the identifier of the first Flutter container (assuming ABC) is automatically read from the first Flutter container, and the identifier of the second Flutter container (assuming DEF) is automatically read from the second Flutter container.
[0083] Step 205: The Flutter web end sends the identifier of the Flutter container and the method name to the native platform based on the Flutter Plugin method.
[0084] Continuing the previous example, the Flutter web end sends the identifier ABC and the identifier DEF and the method name ReceiveMsg to the native platform based on the Flutter Plugin method.
[0085] Step 206: The native platform determines the Flutter container that needs to establish a message channel with the native platform based on the identifier of the Flutter container.
[0086] Continuing the previous example, the native platform determines that the first Flutter container and the second Flutter container are Flutter containers that need to establish a message channel with the native platform based on the identifier ABC and the identifier DEF.
[0087] Step 207: Establish a message channel between the native platform and the Flutter container, which can be invoked by the method name.
[0088] Continuing the above example, a first message channel between the native platform and the first Flutter container is established, which is adapted to be invoked by the method name ReceiveMsg, and a second message channel between the native platform and the second Flutter container is established, which is adapted to be invoked by the method name ReceiveMsg. It can be seen that the first message channel contains the binding relationship between the native platform and the first Flutter container, and the second message channel contains the binding relationship between the native platform and the second Flutter container. Therefore, without the developer remembering the identifier of the message channel, the binding between the native platform and the Flutter container can be achieved.
[0089] Step 208: When the calling command containing the method name is retrieved in the business code of the native platform, the identifier of the target Flutter container as the data receiving object is obtained from the calling command.
[0090] Continuing the above example, when the calling command containing ReceiveMsg is retrieved in the business code of the native platform, the identifier of the target Flutter container is further obtained from the calling command. Assuming that the identifier of the target Flutter container in the calling command is DEF, the second Flutter container is determined as the target Flutter container.
[0091] Step 209: Based on the identifier of the target Flutter container, the message channel between the native platform and the target Flutter container is determined.
[0092] Continuing the above example, based on the identifier DEF of the second Flutter container, the message channel between the native platform and the second Flutter container is determined as the second message channel.
[0093] Step 210: Based on the message channel, data is sent from the native platform to the target Flutter container.
[0094] Continuing the above example, the collected value of the current power of the device contained in the calling command is assigned to the current power variable in the method ReceiveMsg(). After the method ReceiveMsg() is assigned, the processing logic is executed to calculate the standby time. The native platform sends data containing the standby time to the second Flutter container through the second message channel.
[0095] Step 211: The target Flutter container receives the data.
[0096] The second Flutter container receives the data containing the standby time. Then, display can be performed on the standby time in the second Flutter container, or subsequent processing such as secondary development is performed on the standby time.
[0097] Figure 3 is an exemplary structural diagram of a data transmission device between a native platform and a Flutter platform of an embodiment of the present application.
[0098] As shown in Figure 3 , the data transmission device 300 includes:
[0099] A registration module 301 is configured to register, on a Flutter web page containing a Flutter container, a method for obtaining data for the Flutter container.
[0100] A sending module 302 is configured to send, on the Flutter web page, a method name of the method and an identifier of the Flutter container to the native platform.
[0101] An establishment module 303 is configured to establish, on the native platform, a message channel between the native platform and the Flutter container, which is adapted to be called by the method name, based on the identifier of the Flutter container.
[0102] A transmission module 304 is configured to transmit data between the native platform and the Flutter container based on the message channel.
[0103] In an exemplary embodiment, the data transmission device further includes a pop-up module 305 configured to set, on the native platform, the identifier of the Flutter container and attribute parameters of the Flutter container; create the Flutter container on the native platform based on the identifier of the Flutter container and the attribute parameters of the Flutter container; send, on the native platform, a pop-up instruction to the Flutter web page based on an event channel between the native platform and the Flutter web page, the pop-up instruction being used to instruct to pop up the Flutter container; and pop up the Flutter container on the Flutter web page based on the pop-up instruction.
[0104] In an exemplary embodiment, the sending module 302 is configured to send, to the native platform, the method name and the identifier of the Flutter container based on a Flutter Plugin manner.
[0105] In an exemplary embodiment, the transmission module 304 is configured to, when the calling command containing the method name is retrieved in the service code of the native platform, obtain the identification of the target Flutter container as a data receiving object from the calling command; determine the message channel between the native platform and the target Flutter container based on the identification of the target Flutter container; and send at least one of the following data from the native platform to the target Flutter container based on the message channel between the native platform and the target Flutter container: data originating from the native platform; data originating from the cloud.
[0106] In summary, in the embodiments of the present application, the method for obtaining data is registered in the Flutter web page end containing the Flutter container; the method name of the method and the identification of the Flutter container are sent to the native platform; based on the identification of the Flutter container, the message channel between the native platform and the Flutter container adapted to be called by the method name is established; and based on the message channel, data is transmitted between the native platform and the Flutter container. It can be seen that, in the embodiments of the present application, the native platform establishes the message channel between the Flutter container corresponding to the identification which can be called by the method name based on the identification of the Flutter container, that is, the binding of the message channel and the Flutter container is achieved, so that the developer does not need to remember the identification of the message channel, and the data transmission between the native platform and the Flutter platform can be achieved.
[0107] Moreover, in the embodiments of the present application, by applying the calling command containing the method name in the service code of the native platform, data can be conveniently sent to the target Flutter container. Moreover, the type of data sent to the target Flutter container has various embodiments and has wide applicability.
[0108] The embodiment of the present application further provides a computer readable medium, and the computer readable storage medium stores instructions, and the instructions can execute the steps in the data transmission method between the native platform and the Flutter platform when executed by a processor. The computer readable medium in practical application can be included in the device / apparatus / system described in the above embodiment, or can exist independently without being assembled into the device / apparatus / system. The computer readable storage medium carries one or more programs, and when the one or more programs are executed, the data transmission method between the native platform and the Flutter platform described in the above embodiments can be implemented. According to the embodiment of the present application, the computer readable storage medium can be a non-volatile computer readable storage medium, for example, can include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above, but not for limiting the scope of protection of the present application. In the embodiment of the present application, the computer readable storage medium can be any tangible medium containing or storing a program, which can be used or combined with an instruction execution system, apparatus or device.
[0109] As shown in Figure 4 , the embodiment of the present application further provides an electronic device, wherein the device implementing the method of the embodiment of the present application can be integrated. As shown in Figure 4 , it shows an exemplary structure diagram of the electronic device related to the embodiment of the present application,
[0110] Specifically: the electronic device can include a processor 901 with one or more processing cores, a memory 902 with one or more computer readable storage media, and a computer program stored on the memory and executable on the processor. When executing the program of the memory 902, the data transmission method between the native platform and the Flutter platform can be implemented.
[0111] In practical application, the electronic device can further include a power supply 903, an input unit 904, and an output unit 905, and the like. Those skilled in the art can understand that Figure 4The structure of the electronic device shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than shown, or combine certain components, or different component arrangements. Among them: the processor 901 is the control center of the electronic device, connects various parts of the entire electronic device through various interfaces and lines, performs various functions of the server and processes data by running or executing software programs and / or modules stored in the memory 902, and calling data stored in the memory 902, thereby overall monitoring the electronic device. The memory 902 can be used to store software programs and modules, that is, the above-mentioned computer readable storage medium. The processor 901 performs various function applications and data processing by running the software programs and modules stored in the memory 902. The memory 902 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required by at least one function, etc.; the data storage area can store data created according to the use of the server, etc. In addition, the memory 902 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. Accordingly, the memory 902 can also include a memory controller to provide access for the processor 901 to the memory 902.
[0112] The electronic device also includes a power supply 903 for powering various components, which can be logically connected to the processor 901 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 903 can also include one or more direct current or alternating current power supplies, recharging systems, power failure detection circuits, power converters or inverters, power state indicators, and any other components. The electronic device can also include an input unit 904, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls. The electronic device can also include an output unit 905, which can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces, which can be composed of graphics, text, icons, video, and any combination thereof.
[0113] The embodiment of the present application also provides a computer program product, which includes computer instructions for implementing the data transmission method between the native platform and the Flutter platform as described in any of the above embodiments when executed by a processor.
[0114] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments disclosed in this invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in the order specified in the drawings. For example, two blocks shown connected together may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0115] This document describes the principles and implementation methods of the present invention using specific embodiments. These embodiments are merely illustrative of the method and core concepts of the present invention and are not intended to limit the invention. Those skilled in the art can make changes to the specific implementation methods and application scope based on the ideas, spirit, and principles of the present invention. Any modifications, equivalent substitutions, or improvements made should be included within the scope of protection of this invention.
Claims
1. A method for data transmission between a native platform and a Flutter platform, characterized in that, The method comprises the following steps: The native platform creates a Flutter container; The native platform sends a pop-up instruction to the Flutter web page based on an event channel between the Flutter web page and the native platform, and the pop-up instruction is used to instruct to pop up the Flutter container; The Flutter container is popped up in the Flutter web page; In the Flutter web page containing the Flutter container, a method for obtaining data for the Flutter container is registered; In the Flutter web page, the method name of the method for obtaining data for the Flutter container and the identifier of the Flutter container are sent to the native platform; In the native platform, a message channel between the native platform and the Flutter container is established based on the identifier of the Flutter container, and the message channel is adapted to be called by the method name; Based on the message channel, data is transmitted between the native platform and the Flutter container, comprising: when a calling command containing the method name is retrieved in the business code of the native platform, the identifier of the target Flutter container as a data receiving object is obtained from the calling command; based on the identifier of the target Flutter container, the message channel between the native platform and the target Flutter container is determined; based on the message channel between the native platform and the target Flutter container, at least one of the following data is sent from the native platform to the target Flutter container: data originating from the native platform; data originating from the cloud.
2. The method of claim 1, wherein, The method name and the identifier of the Flutter container are sent to the native platform, comprising: The method name and the identifier of the Flutter container are sent to the native platform based on the Flutter Plugin method.
3. An apparatus for data transmission between a native platform and a Flutter platform, characterized in that, The method comprises the following steps: The registration module is used to register a method for obtaining data for the Flutter container in the Flutter web page containing the Flutter container; The sending module is used to send the method name of the method for obtaining data for the Flutter container and the identifier of the Flutter container to the native platform in the Flutter web page; The establishment module is used to establish a message channel between the native platform and the Flutter container based on the identifier of the Flutter container in the native platform, and the message channel is adapted to be called by the method name; The transmission module is used to transmit data between the native platform and the Flutter container based on the message channel; The pop-up module is used to set the identifier of the Flutter container and the attribute parameters of the Flutter container in the native platform, and the Flutter container is created based on the identifier of the Flutter container and the attribute parameters of the Flutter container in the native platform; The native platform sends a pop-up instruction to the Flutter web end based on an event channel between the native platform and the Flutter web end, the pop-up instruction being used to instruct to pop up the Flutter container; and the Flutter web end pops up the Flutter container based on the pop-up instruction. The transmission module is configured to: when an invocation command containing the method name is retrieved in the service code of the native platform, obtain an identifier of a target Flutter container as a data receiving object from the invocation command; determine a message channel between the native platform and the target Flutter container based on the identifier of the target Flutter container; and send at least one of the following data from the native platform to the target Flutter container based on the message channel between the native platform and the target Flutter container: data originating from the native platform; and data originating from the cloud.
4. A computer readable storage medium having stored thereon computer instructions, wherein, The instructions, when executed by a processor, implement the data transmission method between the native platform and the Flutter platform of claim 1 or 2.
5. An electronic device, comprising: The electronic device includes: a processor; a memory for storing executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the data transmission method between the native platform and the Flutter platform of claim 1 or 2.
6. A computer program product, characterised in that, The instructions, when executed by a processor, implement the data transmission method between the native platform and the Flutter platform of claim 1 or 2. The instructions, when executed by a processor, implement the data transmission method between the native platform and the Flutter platform of claim 1 or 2.
Citation Information
Patent Citations
Code block calling method and device and cross-platform code block calling system
CN113138766A
Data interaction method and device, storage medium and electronic equipment
CN114090134A