admin管理员组

文章数量:1355713

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());
     },
),

本文标签: flutterHow to show logs from another applicationStack Overflow