FLUTTER ECOSYSTEM

AS-Devs/signalr_flutter

一個用於 .net SignalR 客戶端的 Flutter 外掛程式。

signalr_flutter 專案封面
Stars
20
Forks
39
最近推送(UTC)
2025年8月10日
專案狀態
未封存
AS Devs GitHub avatar
GITHUB Organization

AS Devs ↗

Two newbies effort to learn & explore the vast universe of Software Development.

Kolkata, India官方網站 ↗
語言SwiftDartJavaObjective-CKotlinJavaScriptRubyShell

技術主題

此儲存庫發佈的套件

使用的依賴

依賴清單 4 項
  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}
  • flutter_lints開發依賴^6.0.0
  • pigeon開發依賴^4.2.5

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

signalr_flutter

A flutter plugin for .net SignalR client.

Usage

First of all, Initialize SignalR and connect to your server.

SignalR signalR = SignalR(
        '<Your server url here>',
        "<Your hub name here>",
        hubMethods: ["<Your Hub Method Names>"]
        statusChangeCallback: (status) => print(status),
        hubCallback: (methodName, message) => print('MethodName = $methodName, Message = $message'));
signalR.connect();

Here statusChangeCallback will get called whenever connection status with server changes.

hubCallback will receive calls from the server if you subscribe to any hub method. You can do that with hubMethods.

hubMethods are the hub method names you want to subscribe.

There is a headers parameters also which takes a Map<String, String>.

You can also invoke any server method.

signalR.invokeMethod("<Your method name here>", arguments: ["argument1", "argument2"]);

If you are trying to connect with a HTTP url, then you need to add the following lines to the manifest of your android project.

<application
        android:usesCleartextTraffic="true">
</application>

This is because of the Network Security Config.

R8 may strip away some SignalR classes for the Android in Release Builds. Add the following line in your proguard-rules.pro file to solve this issue.

-keep class microsoft.aspnet.signalr.client.hubs.** { *; }

For more info check example.

Any issue or PR is always welcome.