messaging_signalr 0.0.2 copy "messaging_signalr: ^0.0.2" to clipboard
messaging_signalr: ^0.0.2 copied to clipboard

-> Package hold and manage all data's and functions needed for Messaging between applications using signalr also send notif when it's needed consider this package is private and using it need to be co [...]

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:messaging_signalr/messaging_signalr.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  SignalRMessaging signalRMessaging = SignalRMessaging();

  @override
  void initState() {
    SignalRMessaging.init(
      onCreateGroup: (_) {
        setState(() {});
      },
      onReceiveNewMessage: (_) {
        setState(() {});
      },
      onGetContactInfoCanceled: (_) {
        setState(() {});
      },
      onGetContactInfo: () {
        setState(() {});
      },
      onSendMessage: () {
        setState(() {});
      },
      firebaseToken: "",
      serverAddress: "your signalr Server Address",
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text("example for usage of messaging_signalr"),
          leading: Text("My Id is: ${signalRMessaging.myId}"),
        ),
        body: ListView(
          children: [
            ...signalRMessaging.chats.map((e) => Container(
                  height: 60,
                  decoration: const BoxDecoration(
                      border: Border(
                          bottom: BorderSide(
                              width: 1.0,
                              color: Colors.black,
                              style: BorderStyle.solid))),
                  child: Row(
                    children: [
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 8.0),
                        child: CircleAvatar(
                          backgroundImage: e.image != null
                              ? MemoryImage(base64.decode(e.image!))
                              : const AssetImage("assets/images/4.jpg")
                                  as ImageProvider,
                          radius: 25,
                        ),
                      ),
                      Expanded(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Padding(
                              padding: const EdgeInsets.only(bottom: 8.0),
                              child: Text(
                                e.userName ?? e.chatId,
                                style: const TextStyle(
                                    fontSize: 27,
                                    fontWeight: FontWeight.bold,
                                    color: Colors.black),
                              ),
                            ),
                            Text(
                              e.messages.isNotEmpty
                                  ? "${e.messages[0].senderUserName} : ${e.messages[0].text}"
                                  : "",
                              style: const TextStyle(
                                color: Colors.black54,
                              ),
                            ),
                          ],
                        ),
                      ),
                      Expanded(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: [
                            Padding(
                              padding: const EdgeInsets.only(top: 8.0),
                              child: Text(
                                e.messages.isNotEmpty
                                    ? "${e.messages[0].date?.hour}: ${e.messages[0].date?.minute}"
                                    : "",
                                style: const TextStyle(color: Colors.grey),
                              ),
                            ),
                          ],
                        ),
                      )
                    ],
                  ),
                ))
          ],
        ),
      ),
    );
  }
}
0
likes
120
points
65
downloads

Publisher

verified publisherabomis.com

Weekly Downloads

-> Package hold and manage all data's and functions needed for Messaging between applications using signalr also send notif when it's needed consider this package is private and using it need to be connected to abmois company's servers.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, flutter, http, signalr_core

More

Packages that depend on messaging_signalr