eko 0.0.1 copy "eko: ^0.0.1" to clipboard
eko: ^0.0.1 copied to clipboard

Eko for connecting your flutter to laravel reverb.

πŸ“‘ Eko a Flutter Laravel Reverb Client #

πŸš€ Features #

βœ”οΈ Easy WebSocket Connection to Laravel Reverb
βœ”οΈ Authentication Support (JWT, API Keys)
βœ”οΈ Public & Private Channel Subscriptions
βœ”οΈ Real-time Event Handling
βœ”οΈ Lightweight & Easy to Use

πŸ“¦ Installation #

Add eko to your pubspec.yaml:

dependencies:
  eko: ^0.0.1

and run:

flutter pub get

or install it from the command line:

flutter pub add eko

🎯 Usage #

1️⃣ Initialize the WebSocket Client #

import 'package:eko/eko.dart';

final options = EkoOptions(
  scheme: "ws",
  host: "localhost",
  port: "8080",
  appKey: "your-app-key", // Reverb app key
  authUrl: "https://your-backend.com/api/broadcasting/auth", // optional, needed for private channels
  authToken: "your-auth-token", // optional
  privatePrefix: "private-", // default: "private-"
);

final eko = Eko(options: options);

2️⃣ Listen for Messages #

// Public channel
eko.listen((message) {
  print("Received: ${message.event}, Data: ${message.data}");
}, "public-channel", isPrivate: false);

// Private channel
eko.listen((message) {
print("Received: ${message.event}, Data: ${message.data}");
}, "public-channel", isPrivate: true);

3️⃣ Close Connection #

eko.close();

πŸ§ͺ Testing #

Unit tests are included and use mockito to simulate WebSocket interactions: TODO

flutter test

πŸ›  Configuration #

Parameter Type Description
scheme String WebSocket scheme (ws or wss)
host String Server hostname
port String Server port
appKey String Laravel Echo app key
authUrl String? URL for authentication (private channels)
authToken String? Token for authentication requests (sanctum or similar)
privatePrefix String Prefix for private channels (default: private-)

EkoOptions example #

class EkoOptions {
  final String scheme;
  final String host;
  final String port;
  final String appKey;
  final dynamic authToken;
  final String? authUrl;
  final String privatePrefix;
  final bool usePrefix;

  EkoOptions({
    required this.scheme,
    required this.host,
    required this.port,
    required this.appKey,
    this.authToken,
    this.authUrl,
    this.privatePrefix = 'private-',
    this.usePrefix = true,
  });
}
1
likes
130
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

Eko for connecting your flutter to laravel reverb.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, logger, web_socket_channel

More

Packages that depend on eko