flutter_xmpp 0.0.30

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

flutter_xmpp #

XMPP for realtime chat communication, this plugin just only work for android ..

Still Development #

Getting Started #

Example #

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:async';
import 'package:flutter_xmpp/flutter_xmpp.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String rerceiveMessageFrom = '';
  String rerceiveMessageBody = '';

  FlutterXmpp flutterXmpp;

  @override
  void initState() {
    super.initState();
    initXmpp();
  }


  @override
  void dispose() async{
    await flutterXmpp.stop();
    super.dispose();
  }

  Future<void> initXmpp() async{
    var auth = {
      "user_jid": "papua-dev@0.0.0.0/Android",
      "password":"papua-dev",
      "host":"0.0.0.0",
      "port":5222
    };
    flutterXmpp = new FlutterXmpp(auth);

    // login
    await flutterXmpp.login();

    // start listening receive message
    await flutterXmpp.start(_onReceiveMessage,_onError);

    sleep(const Duration(seconds:2)); // just sample wait for get current state

    print(await flutterXmpp.currentState()); // get current state

    // sending Message
    await flutterXmpp.sendMessage("xbon@0.0.0.0","Kirim Pesan Bro","random_id_for_sync_with_sqlite");


    // read Message
    await flutterXmpp.readMessage("xbon@0.0.0.0","random_id_for_sync_with_sqlite");


    // life cycle, if app not active, kill stream get incoming message ..
    lifeCycle();

    // logout
    await flutterXmpp.logout();

  }

  void lifeCycle() async{
    SystemChannels.lifecycle.setMessageHandler((msg) async{
      if(msg == "AppLifecycleState.inactive" || msg == "AppLifecycleState.suspending" ){
        await flutterXmpp.stop();
      }else if(msg == "AppLifecycleState.resumed"){
        await flutterXmpp.start(_onReceiveMessage, _onError);
      }
      print('SystemChannels> $msg');
      return "Lifecycle";
    });
  }

  void _onReceiveMessage(dynamic event) {
    print(event);
    if(event["type"] == "incoming") {
      setState(() {
        rerceiveMessageFrom = event['from'];
        rerceiveMessageBody = event['body'];
        rerceiveMessageBody = event['id']; // chat ID
      });
    } else {
      setState(() {
        rerceiveMessageFrom = event['to'];
        rerceiveMessageBody = event['body'];
        rerceiveMessageBody = event['id']; // chat ID
      });
    }
  }

  void _onError(Object error) {
    print(error);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('FlutterXMPP'),
        ),
        body: Center(
          child: Text('Incoming or Outgoinng Message: \n$rerceiveMessageFrom\n$rerceiveMessageBody'),
        ),
      ),
    );
  }
}

0.0.30 #

  • update github home url

0.0.29 #

  • remove log debug

0.0.28 #

  • fix bug

0.0.27 #

  • fix bug

0.0.24 #

  • Add Read Message Status

0.0.23 #

  • Remove Connstructor

0.0.22 #

  • Separate Login & Logout

0.0.21 #

  • Fix Bug

0.0.20 #

  • Add Rquired ID chat For Sending Message, this is for sync data with local DB (SQLITE) for features Message (Read and Unread) And another Status

0.0.19 #

  • Add Broadcast Receiver

0.0.18 #

  • Fix BUG

0.0.17 #

  • Add outgoing message

0.0.16 #

  • If Send Message, Send to self for notif all user already login in another resource

0.0.14 #

  • Add Current State

0.0.6 #

  • Update Plugin Description

0.0.5 #

  • Update Receiver Message

0.0.1-dev.1 #

  • Update readme

0.0.1 #

  • TODO: Describe initial release.

example/README.md

flutter_xmpp_example #

Demonstrates how to use the flutter_xmpp plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_xmpp: ^0.0.30

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_xmpp/flutter_xmpp.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

14 out of 14 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/flutter_xmpp.dart. (-1.49 points)

Analysis of lib/flutter_xmpp.dart reported 3 hints:

line 25 col 62: Name non-constant identifiers using lowerCamelCase.

line 35 col 67: Name non-constant identifiers using lowerCamelCase.

line 45 col 50: Name non-constant identifiers using lowerCamelCase.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test