简体   繁体   English

我可以在 flutter 模块中定义的 android 项目中看到 class

[英]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.

相关问题 我们可以将Flutter模块添加到现有的Android Studio项目中吗? - Can we add a Flutter module to an existing Android Studio project? 将flutter模块添加到android项目时无法触发onActivityResult - onActivityResult can't triggered when add flutter module to android project Android Studio:如何查看未使用的资源? - Android Studio: How can I see which resources are not used? 我在 Android Studio 中创建了一个新的 KMM 项目,在 Android 视图中看不到 androidMain 模块 - I create a new KMM project in Android studio and don't see the androidMain module in Android View 我在哪里可以看到 Android Studio 中某个类的所有方法? - Where I can see all the methods of a class in Android studio? 如何定义动态数据 class? (Android - Retrofit2) - How can I define dynamic data class? (Android - Retrofit2) 如何在android studio中查看android项目中添加模块的日志 - how to see the logs of added module in android project in android studio 如何在 Android Studio 上打开一个新的 flutter 项目? - How can I open a new flutter project on Android Studio? 如何将此模块添加到我的Android Studio项目中? - How can I add this module to my Android Studio project? Android Studio 中的哪些配置定义了一个 android 项目的模块之间的差异 - Which configurations in Android Studio define the differences between modules of a android project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM