aerosync_flutter_sdk 1.0.0-dev-4 copy "aerosync_flutter_sdk: ^1.0.0-dev-4" to clipboard
aerosync_flutter_sdk: ^1.0.0-dev-4 copied to clipboard

This Flutter SDK provides an interface to load Aerosync-UI in Flutter apps.

example/main.dart

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

void main() => runApp(UrlLauncherPage());

class UrlLauncherPage extends StatefulWidget {
  UrlLauncherPage({Key? key}) : super(key: key);
  @override
  UrlLauncherExample createState() => UrlLauncherExample();
}

class UrlLauncherExample extends State<UrlLauncherPage> {
  static const String _title = 'URL Launcher Example';
  late String _token = "";
  late String _env = "dev";
  late String _deeplink = "";
  Map _style = {};
  late bool isLoading;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: isLoading
            ? LaunchButton(
                env: _env, token: _token, style: _style, deeplink: _deeplink)
            : SizedBox(), // this includes all the button and functionality
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    isLoading = false;
  }
}

class LaunchButton extends StatelessWidget {
  var env;
  var token;
  var style;
  var deeplink;
  LaunchButton(
      {Key? key,
      required this.env,
      required this.token,
      required this.style,
      required this.deeplink})
      : super(key: key);

  // handle the OnEvent callback from aerosync
  handleOnEventAerosync(eventType, data) {
    print("CALLBACK FULLY HANDLED: OnEvent");
  }

  // handle the OnSuccess callback from aerosync
  handleOnSuccessAerosync(eventType, data) {
    print("CALLBACK FULLY HANDLED: OnSuccess");
    print(data);
  }

  // handle the OnClose callback from aerosync
  handleOnCloseAerosync(eventType, data) {
    print("CALLBACK FULLY HANDLED: OnClose");
  }

  // handle the OnLoad callback from aerosync
  handleOnLoadAerosync(eventType, data) {
    print("CALLBACK FULLY HANDLED: OnLoad");
  }

  // handle the OnError callback from aerosync
  handleOnErrorAerosync(eventType, data) {
    print("CALLBACK FULLY HANDLED: OnError");
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      mainAxisSize: MainAxisSize.min,
      children: [
        ElevatedButton(
          onPressed: () => {
            Navigator.of(context).push(MaterialPageRoute(
                builder: (context) => AerosyncSDKPage(
                      env: env,
                      token: token,
                      style: style,
                      onEvent: handleOnEventAerosync,
                      onSuccess: handleOnSuccessAerosync,
                      onClose: handleOnCloseAerosync,
                      onLoad: handleOnLoadAerosync,
                      onError: handleOnErrorAerosync,
                      deeplink: deeplink,
                    )))
          },
          child: Text(
            'Connect',
            style: TextStyle(fontSize: 20),
          ),
        ),
      ],
    ));
  }
}
1
likes
0
points
202
downloads

Publisher

unverified uploader

Weekly Downloads

This Flutter SDK provides an interface to load Aerosync-UI in Flutter apps.

Homepage

License

unknown (license)

Dependencies

cupertino_icons, flutter, flutter_inappwebview, lottie, uuid

More

Packages that depend on aerosync_flutter_sdk