flutter_jitter 0.0.3 copy "flutter_jitter: ^0.0.3" to clipboard
flutter_jitter: ^0.0.3 copied to clipboard

A Laravel Reverb WebSocket client for Flutter.

๐Ÿ“ก Jitter a Flutter Laravel Reverb WebSocket 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 flutter_jitter to your pubspec.yaml:

dependencies:
  flutter_jitter: ^0.0.1

and run:

flutter pub get

or install it from the command line:

flutter pub add flutter_jitter

๐ŸŽฏ Usage #

1๏ธโƒฃ Initialize the WebSocket Client #

import 'package:flutter_jitter/flutter_jitter.dart';

final options = FlutterJitterOptions(
  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 jitter = FlutterJitter(options: options);

2๏ธโƒฃ Listen for Messages #

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

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

3๏ธโƒฃ Close Connection #

jitter.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-)

FlutterJitterOptions example #

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

  FlutterJitterOptions({
    required this.scheme,
    required this.host,
    required this.port,
    required this.appKey,
    this.authToken,
    this.authUrl,
    this.privatePrefix = 'private-',
    this.usePrefix = true,
  });
}
0
likes
120
points
69
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Laravel Reverb WebSocket client for Flutter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, http, logger, web_socket_channel

More

Packages that depend on flutter_jitter