meeting500mg 0.0.1 copy "meeting500mg: ^0.0.1" to clipboard
meeting500mg: ^0.0.1 copied to clipboard

Meeting500mg

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:meeting500mg/meeting500mg_plugin.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]);


  await Meeting500MGPlugin.initializePlugin(
    clientId: '<client-Id>',
    clientSecret: '<client-secret>',
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Meeting500MGPlugin.wrapWithBlocProviders(
        child: Scaffold(body: ConnectHelp()),
      ),
    );
  }
}

class ConnectHelp extends StatefulWidget {
  const ConnectHelp({super.key});

  @override
  State<ConnectHelp> createState() => _ConnectHelpState();
}

class _ConnectHelpState extends State<ConnectHelp> {
  bool _isCallActive = false;
  bool _isInitialized = false;

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

  Future<void> _initPlugin() async {

    await Meeting500MGPlugin.joinCall(
      dealerName: "<dealer-name>",
      email: "<email>",
      customerMobile: "<phone>",
      dealerCode: "<dealer-code>",
      language: "<language>",
      agenda: "<agenda>",
    );

    setState(() {
      _isInitialized = true;
    });
  }

  void _onCallStarted() => setState(() => _isCallActive = true);
  void _onCallEnded() => setState(() => _isCallActive = false);

  @override
  Widget build(BuildContext context) {
    if (!_isInitialized) {
      return const Center(child: CircularProgressIndicator());
    }

    return Scaffold(
      backgroundColor: Colors.white,
      body: Stack(
        children: [
          Positioned(
            top: 40,
            right: 16,
            child: ElevatedButton(
              onPressed: () {
                Meeting500MGPlugin.startCall();
              },
              child: const Text("Click to Call"),
            ),
          ),
          Positioned.fill(
            child: Visibility(
              visible: _isCallActive,
              maintainState: true,
              child: Meeting500MGPlugin.getMainHomeScreen(
                onCallStarted: _onCallStarted,
                onCallEnded: _onCallEnded,
              ),
            ),
          ),
        ],
      ),
    );
  }
}