最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

flutter - How to show logs from another application? - Stack Overflow

programmeradmin1浏览0评论

I am writing two applications. The first is a server dart application, which works via the Windows command line. The second is a flutter client application, with a user interface. The applications exchange data via a web server deployed in the first application.

In the first application, logs are output to the Windows command line via < print >. How can I get these logs in real time in the second application?

There is an idea to get logs via riverpod or by writing/reading logs from an external file, but I think this is not optimal.

I am writing two applications. The first is a server dart application, which works via the Windows command line. The second is a flutter client application, with a user interface. The applications exchange data via a web server deployed in the first application.

In the first application, logs are output to the Windows command line via < print >. How can I get these logs in real time in the second application?

There is an idea to get logs via riverpod or by writing/reading logs from an external file, but I think this is not optimal.

Share Improve this question asked Mar 28 at 6:25 Артем ИльинскийАртем Ильинский 2991 silver badge10 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 1

I suggest you create an API, such as using Node.JS.

This API will serve as a middleman data access layer between your apps, regardless of platform or type of apps.

You have to use a single API service across your apps, then add some logic for how you transfer and retrieve log data while interacting with your apps.

Riverpod would also be useful in handling state changes management.

Also, I recommend dio which will serve as:

A powerful HTTP networking package for Dart/Flutter, supports Global configuration, Interceptors, FormData, Request cancellation, File uploading/downloading, Timeout, Custom adapters, Transformers, etc.

It is pretty useful if you integrate them into your system architecture.

I hope this helps!

https://developer.android/tools/logcat

You can use logcat to get logs of devices from all apps

Use a websocket server, to send the logs to the client. Then use the StreamBuilderWidget, and use the websocket like that.

final channel = IOWebSocketChannel.connect('ws://localhost:8080');
StreamBuilder(
    stream: channel.stream,
    builder: (context, snapshot) {
        if (snapshot.hasData) {
            return Text(snapshot.data.toString());
        }
        return Center(child: CircularProgressIndicator());
     },
),
发布评论

评论列表(0)

  1. 暂无评论