qbox_widget_webview 0.3.6 copy "qbox_widget_webview: ^0.3.6" to clipboard
qbox_widget_webview: ^0.3.6 copied to clipboard

unlisted

QBox widget WebView library

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:qbox_widget_webview/index.dart' as qbox;

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example',
      theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.black)),
      home: const MyHomePage(title: 'Example'),
      debugShowCheckedModeBanner: false,
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late final qbox.WebWidget qboxWidget;

  String? pipState;

  @override
  void initState() {
    qboxWidget = qbox.WebWidget(
      const qbox.Settings(
        // url: 'https://kenes.1414.kz/widget/v2?ai=yes',
        url: 'https://inqbox.q19.kz/widget/v2?ai=yes&is_mobile=true',
        language: qbox.Language.ru,
        user: qbox.User(
          firstName: 'Johny',
          lastName: 'Apple',
          patronymic: 'Seed',
          iin: '112233445566',
          phoneNumber: '77771234567',
        ),
        call: qbox.Call(
          type: qbox.CallType.video, // audio = qbox.CallType.audio
          domain: 'test.kz',
          topic: 'test',
          dynamicAttrs: {'foo': 'bar'},
        ),
        loggingEnabled: false,
      ),
      qbox.Callbacks(
        onPageLoadProgress: (progress) {
          debugPrint('onPageLoadProgress: $progress');
        },
        onPageLoadFinished: (url) {
          debugPrint('onPageLoadFinished: $url');
        },
        onCallState: (String state) {
          debugPrint('onCallState: $state');
        },
        onPiPState: (String state) {
          debugPrint('onPiPState: $state');
          setState(() {
            pipState = state;
          });
        },
      ),
    );

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar:
          pipState == null || pipState == 'exited'
              ? AppBar(backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title))
              : null,
      body: qboxWidget,
    );
  }
}