[英]Can i see class in android project which is define in flutter module
I want to define a class in flutter module and in this class there will be 2 functions.我想在 flutter 模块中定义一个 class,在这个 class 中将有 2 个函数。 I want to create instance for this class in android project and set settings for this class (with constructor).
我想在 android 项目中为此 class 创建实例并为此 class 设置设置(使用构造函数)。
And I want call the function which is define in this class.One of them return List string, other func will be return widgert and with this I want to render widget in android with FlutterView.我想调用在这个 class 中定义的 function。其中一个返回列表字符串,其他函数将返回 widgert 并且我想用 FlutterView 在 android 中呈现小部件。 Is it possible?
可能吗?
MyClass {
typeRest string
useDebug bool
func Func1{
do something with this.typeRest and this.useDebug
and return list<String>
}
func Func2 {
do something with this.typeRest and this.useDebug
and return widget
}
}
I added flutter module to android project but I can not see myclass in android project so I can not create instance.我将 flutter 模块添加到 android 项目,但在 android 项目中看不到 myclass,因此无法创建实例。
You can have communication between the 2 sides, but generally the Flutter side does the invocation using a MethodChannel and you can have some java/kotlin code that responds to it.您可以在双方之间进行通信,但通常 Flutter 方使用MethodChannel进行调用,您可以使用一些 java/kotlin 代码来响应它。 You can find tutorials online on how to do this.
您可以在线找到有关如何执行此操作的教程。
If you want to send some information to the Flutter side, you have to get the Flutter/Dart code to request it instead.如果要向Flutter端发送一些信息,则必须获取Flutter/Dart代码来请求它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.