stream24 0.1.2 copy "stream24: ^0.1.2" to clipboard
stream24: ^0.1.2 copied to clipboard

outdated

A flutter plugin for creating 24Stream Rich Page widgets.

24Stream Flutter #

A flutter plugin for creating 24Stream Rich Page widgets.

Installation #

To install add stream24 plugin to your dependencies in your pubspec.yaml

dependencies:
  ...
  stream24: ^0.1.1
...

Usage #

Stream24RichPage

A webview widget with rich html contents and automatic height.

Parameter Type Description
brand string Required. Brand name for the page
productId string Required. Prouct ID for the page
retailerDomain string Required. Domain of the retailer of the page
templateType string Required. Template type of the page
language string Language code for the page encoded as country_language. Country code should set according to ISO 3166-1 standard and the language code - to ISO 639-1. Defaults to ru_ru
onError Function(String) A function to call when an error is occured.
resultType Stream24ResultType Result type of the page. One of .json, .html or .iframe. Defaults to .html
contentType Stream24ContentType Content type of the page. One of .shopInShops or .minisite. Defaults to .minisite

getHtml

Returns HTML code of the page as a String.

Parameter Type Description
brand string Required. Brand name for the page
productId string Required. Prouct ID for the page
retailerDomain string Required. Domain of the retailer of the page
templateType string Required. Template type of the page
language string Language code for the page encoded as country_language. Country code should set according to ISO 3166-1 standard and the language code - to ISO 639-1. Defaults to ru_ru
contentType Stream24ContentType Content type of the page. One of .shopInShops or .minisite. Defaults to .minisite

Example #

Example of usage with webview_flutter

using Stream24RichPage

import 'package:flutter/material.dart';
import 'package:stream24/stream24.dart';
import 'package:stream24/rich_page.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewPage extends StatefulWidget {
  WebViewPage({super.key});
  @override
  State<WebViewPage> createState() => _WebViewPageState();
}
class _WebViewPageState extends State<WebViewPage> {
  @override
  Widget build(BuildContext context) {
    return  Stream24RichPage(
            brand: 'Samsung',
            productId: '16651081549',
            retailerDomain: 'irshad.az',
            templateType: 'master_template',
            contentType: Stream24ContentType.shopInShops,
            onError: (errorMsg){ print(errorMsg); }
        );
    }
}

OR

using getHtml

import 'package:flutter/material.dart';
import 'package:stream24/stream24.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewPage extends StatefulWidget {
  WebViewPage({super.key});
  @override
  State<WebViewPage> createState() => _WebViewPageState();
}

class _WebViewPageState extends State<WebViewPage> {
  late WebViewController controller;
    double height = 120;

  @override
  void initState() {
    super.initState();
       controller = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)

      // to automatically adjust height add the following block
      ..addJavaScriptChannel("FlutterWebviewHeight",
          onMessageReceived: (JavaScriptMessage msg) {
        setState(() {
          height = double.tryParse(msg.message) ?? 0;
        });
      })
      //////////////////////////////////////////////////////////////////

      //if you want to throw errors on 404 content add the following block
      ..addJavaScriptChannel("FlutterError",
          onMessageReceived: (JavaScriptMessage msg) {
            
        throw Exception(msg.message);
      })
      //////////////////////////////////////////////////////////////////

      ..loadHtmlString(Stream24.getHtml(
          brand: 'Samsung',
          productId: '16651081549',
          retailerDomain: 'irshad.az',
          templateType: 'master_template',
          contentType: Stream24ContentType.shopInShops));
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        height: height,
        child: WebViewWidget(
          controller: controller,
        ),
    );
  }
}

1
likes
0
points
152
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter plugin for creating 24Stream Rich Page widgets.

Homepage

License

unknown (license)

Dependencies

flutter, webview_flutter

More

Packages that depend on stream24

Packages that implement stream24