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

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.5
...

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

checkContenAvailability

You can also check whether there is rich page with given parameters or not, before deciding whether to show it. Parameters are the same as for GetHtml but also accept completion function, which will be triggered when the result returns.

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
completion Function(Bool) Triggered with input boolean. Boolean contains availability answer

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,
        ),
    );
  }
}

Check content availability

import 'package:stream24/stream24.dart';

//...

Stream24.checkContentAvailability(
        brand: 'TestBrand',
        retailerDomain: '24ttl.ru',
        productId: '920-969696',
        templateType: 'master_template',
        language: 'ru',
        contentType: Stream24ContentType.minisite,
        completion: (available) {
          print("Content is ${avalable? "available" : "unavailable"}")
        });

///...
1
likes
150
points
61
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter plugin for creating 24Stream Rich Page widgets.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, webview_flutter

More

Packages that depend on stream24