pusher_connect 1.0.1 pusher_connect: ^1.0.1 copied to clipboard
A Flutter plugin to integrate into the Pusher service
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:pusher_connect/pusher_connect.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
PusherConnect pusherConnect = new PusherConnect(
appKey: "<APPKEY>",
cluster: "<CLUSTER>",
channel: "my-channel",
event: "my-event",
);
var text = "Send an event to the pusher channel.";
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
pusherConnect.onRecievedEvents.listen((OnRecievedEvent event) {
setState(() {
text = event.data['message'];
});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Pusher Connect Example'),
),
body: Center(
child: Text(text),
),
),
);
}
}