livecom_ios 1.1.2 copy "livecom_ios: ^1.1.2" to clipboard
livecom_ios: ^1.1.2 copied to clipboard

PlatformiOS

The iOS implementation of livecom

example/lib/main.dart

import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:livecom_ios/livecom_ios.dart';
import 'package:livecom_platform_interface/livecom_delegate.dart';
// import 'package:livecom_platform_interface/livecom_conversion_product.dart';

final _liveComPlugin = LiveComIOS.shared;

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    _liveComPlugin.configure(
        "f400270e-92bf-4df1-966c-9f33301095b3",
        "0091FF",
        "#EF5DA8",
        "#0091FF",
        "#00D1FF",
        "https://website.com/{video_id}",
        "https://website.com/{video_id}?p={product_id}"
    );
    _liveComPlugin.delegate = this;
    // _liveComPlugin.useCustomCheckoutScreen = true;
    // _liveComPlugin.useCustomProductScreen = true;
    // _liveComPlugin.trackConversion("flutter_test_order_id", 1300, "USD", [LiveComConversionProduct("test_sku", "test_name", "qQMqXx2wy", 2)]);
    
    return MaterialApp(
      title: 'LiveCom Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter screen'),
    );
  }


  @override
  void onCartChange(List<String> productSKUs) {
    log("[LiveCom] onCartChange productSKUs: ${productSKUs.join(", ")}");
  }
  
  @override
  void onProductAdd(String sku, String streamId) {
    log("[LiveCom] onProductAdd sku: $sku stream_id: $streamId");
  }
  
  @override
  void onProductDelete(String productSKU) {
    log("[LiveCom] onProductDelete sku: $productSKU");
  }
  
  @override
  void onRequestOpenCheckoutScreen(List<String> productSKUs) {
    log("[LiveCom] onRequestOpenCheckoutScreen productSKUs: ${productSKUs.join(", ")}");
  }
  
  @override
  void onRequestOpenProductScreen(String sku, String streamId) {
    log("[LiveCom] onRequestOpenProductScreen sku: $sku stream_id: $streamId");
  }
}

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

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

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


class _MyHomePageState extends State<MyHomePage> {

 String streamId = "qQMqXx2wy";
  final TextEditingController _textFieldController =
      TextEditingController(text: "qQMqXx2wy");

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(
                onPressed: () {
                  _liveComPlugin.presentStreams();
                },
                child: const Text("Show video list")
            ),
            TextButton(
                onPressed: () => showDialog(
                    context: context,
                    builder: (BuildContext context) => AlertDialog(
                          title: const Text('Enter stream id'),
                          content: TextField(
                            onChanged: (value) { streamId = value; },
                            controller: _textFieldController,
                            decoration: const InputDecoration(hintText: "stream id"),
                          ),
                          actions: <Widget>[
                            TextButton(
                              onPressed: () => Navigator.pop(context, 'Cancel'),
                              child: const Text('Cancel'),
                            ),
                            TextButton(
                              onPressed: () {
                                Navigator.pop(context, 'OK');
                                _liveComPlugin.presentStream(streamId);
                              },
                              child: const Text('OK'),
                            ),
                          ],
                        )),
                child: const Text("Show video")
            ),
            TextButton(
              onPressed: () {
                _liveComPlugin.presentStreams();
                _liveComPlugin.presentStream(streamId);
            },
             child: const Text("Show list and video")
            ),
          ],
        ),
      ),
      ),
    );
  }
}
0
likes
130
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

The iOS implementation of livecom

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, livecom_platform_interface, plugin_platform_interface

More

Packages that depend on livecom_ios