en_bot_sdk 1.0.1 copy "en_bot_sdk: ^1.0.1" to clipboard
en_bot_sdk: ^1.0.1 copied to clipboard

outdated

A new Flutter project.

example/lib/main.dart

import 'dart:ffi';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:en_bot_sdk/en_bot_sdk.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await EnBotSdk.platformVersion ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomeWidget(platformVersion: _platformVersion),
    );
  }
}

class HomeWidget extends StatelessWidget {
  const HomeWidget({
    Key? key,
    required String platformVersion,
  }) : _platformVersion = platformVersion, super(key: key);

  final String _platformVersion;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('ENBotSDK example flutter app'),
      ),
      body: ListView(
        padding: const EdgeInsets.symmetric(horizontal: 30),
        children: [
          SizedBox(height: 180,),
          Text('Running on: $_platformVersion\n', textAlign: TextAlign.center,),
          SizedBox(height: 100,),
          OutlinedButton(
            onPressed: () async {
              EnBotSdk sdk = EnBotSdk();
              Object? doneObejct = await sdk.launchBot(context,
                  "9aea492e9f0940c4",
                  "botName",
                  "brandingKey",
                  "4353",
                  100,
                  false,
                  EnBotSdk_LanguageDirection.defaultDirection,
                  "fonts/SofiaProMedium.ttf",
                "fonts/SofiaProMedium.ttf",
                  "Assets/Images/ic_card_scroller_right.png",
              );
              },
              style: ButtonStyle(
                foregroundColor: MaterialStateProperty.all(Colors.white),
                backgroundColor: MaterialStateProperty.all(Colors.lightBlue),
                  shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)))
              ),
              child: const Text("Launch Bot")

          ),
          SizedBox(height: 180,)
        ],

      )
      ,
    );
  }
}
5
likes
0
pub points
60%
popularity

Publisher

unverified uploader

A new Flutter project.

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on en_bot_sdk