Laravel Flutter Pusher

pub package

An unofficial Flutter plugin that wraps pusher-websocket-java on Android and pusher-websocket-swift on iOS. This is a continued plugin for Flutter Pusher Client

This package lets you consume events from a Pusher server. In order to use this library, you need to have a free account on pusher.com. After registering, you will need the application credentials for your app. NOTE This package requires json_annotation : ^4.0.0

How to install

  • Add to your pubspec.yaml
dependencies:
  laravel_flutter_pusher: ^0.0.4

Getting Started

import 'package:laravel_flutter_pusher/laravel_flutter_pusher.dart';

void main() {

  var options = PusherOptions(
          host: '10.0.2.2',
          port: 6001,
          encrypted: false,
          cluster: 'eu'
      );
  
      LaravelFlutterPusher pusher = LaravelFlutterPusher('app_key', options, enableLogging: true);
      pusher
          .subscribe('channel')
          .bind('event', (event) => log('event =>' + event.toString()));
}

Lazy Connect

Connection to the server can be delayed, so set the lazyConnect prop on the client constructor.

R8/Proguard code obfuscation

If you have enabled code obfuscation with R8 or proguard, you need to add the following rule.

android/app/build.gradle:

buildTypes {
  release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}

android/app/proguard-rules.pro:

-keep class com.github.olubunmitosin.laravel_flutter_pusher.** { *; }

Development

Generate the models and the factories: flutter packages pub run build_runner build --delete-conflicting-outputs

Libraries

laravel_flutter_pusher