pusher_connect 1.0.1 copy "pusher_connect: ^1.0.1" to clipboard
pusher_connect: ^1.0.1 copied to clipboard

A Flutter plugin to integrate into the Pusher service

example/lib/main.dart

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),
        ),
      ),
    );
  }
}
0
likes
20
pub points
1%
popularity

Publisher

unverified uploader

A Flutter plugin to integrate into the Pusher service

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on pusher_connect