【问题标题】:How to use external DLL (Dot Net) in Flutter?如何在 Flutter 中使用外部 DLL(Dot Net)?
【发布时间】:2022-02-11 19:53:41
【问题描述】:

我已经使用包含 Web API 的 c# 开发了桌面项目。现在我们计划开始使用 Flutter 在移动平台上进行开发。所以我已经将所有包含计算和操作的函数构建到 DLL 中。那么我可以在 Flutter 中使用这个 DLL 吗?

DLL项目类型“类库(IOS、Android和Windows可移植)

【问题讨论】:

    标签: c# flutter


    【解决方案1】:

    我不这么认为。

    类库(适用于 IOS、Android 和 Windows)

    如果你使用 xamarin,你可以在那里使用 .net 库。

    但是,如果您的项目包含 Web Api,您可以轻松地从中获取数据!

    1. 要安装 http 包,请将其添加到 pubspec.yaml 的依赖项部分
    2. 从你的 asp.net web api 获取数据:
    Future<http.Response> fetchPost() {   return http.get('https://jsonplaceholder.typicode.com/posts/1'); }
    

    更多关于反序列化的信息可以在flutter的官方文档中找到: https://flutter.dev/docs/cookbook/networking/fetch-data

    【讨论】:

      【解决方案2】:

      是的,但必须为每个平台使用本机源代码。 例如:对于 android,使用 http://en.wikipedia.org/wiki/Java_Native_Access 从 dll .net 导入函数; 对于windows,它可以用c ++ ... 我建议您创建一个插件以更好地组织。

      对于 android,此链接可以帮助您: Setting up JNA in Android Studio

      使用 Flutter 与 Java/kotlin 通信:

      import io.flutter.plugin.common.MethodCall;
      import io.flutter.plugin.common.MethodChannel;
      

      【讨论】:

        猜你喜欢
        • 2012-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-29
        • 1970-01-01
        • 2016-02-10
        • 1970-01-01
        相关资源
        最近更新 更多