flutter_support_chat 0.2.0
flutter_support_chat: ^0.2.0 copied to clipboard

Flutter package to implement a firestore chat between customer and product support

example/lib/main.dart

// Flutter imports:
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';

// Package imports:
import 'package:flutter_support_chat/flutter_support_chat.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

import 'login.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'flutter_support_chat example',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("flutter_fb_news example"),
      ),
      body: StreamBuilder<User?>(
        builder: (BuildContext context, AsyncSnapshot<User?> s) {
          if (s.connectionState == ConnectionState.active) {
            if (s.hasData) {
              return StreamBuilder<User?>(
                stream: FirebaseAuth.instance.userChanges(),
                builder: (BuildContext context, AsyncSnapshot<User?> snapshot) {
                  if (snapshot.connectionState == ConnectionState.active) {
                    if (snapshot.hasData) {
                      final User user = snapshot.data!;
                      return FlutterSupportChat(
                        supporterEmails: [
                          'cedtegapps.de@gmail.com',
                        ],
                        currentEmail: user.email!,
                        firestoreInstance: FirebaseFirestore.instance,
                        newCaseText: 'New Support Case',
                        createCaseText: "Create Support Case",
                        writeMessageText: "Write a Message",
                      );
                    }
                  }
                  return RefreshProgressIndicator();
                },
              );
            }
            return Login();
          }
          return RefreshProgressIndicator();
        },
        stream: FirebaseAuth.instance.authStateChanges(),
      ),
    );
  }
}
5
likes
120
pub points
45%
popularity

Publisher

cedtegapps.de

Flutter package to implement a firestore chat between customer and product support

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

cloud_firestore, firebase_core, flutter

More

Packages that depend on flutter_support_chat