flutter_plugin_bbd_application 0.2.0 copy "flutter_plugin_bbd_application: ^0.2.0" to clipboard
flutter_plugin_bbd_application: ^0.2.0 copied to clipboard

Flutter plugin to get access to data that is globally available in any BlackBerry Dynamics Application.

example/lib/main.dart

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

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

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

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    Map<String, dynamic> appConfig;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await FlutterPluginBbdApplication.getVersion;
      appConfig = await FlutterPluginBbdApplication.getApplicationConfig;
    } 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;
      _userId = appConfig['userId'];
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin BBD Application example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('Running on: $_platformVersion\n'),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text('with userId: '),
                  Text(
                    '$_userId',
                    style: TextStyle(fontWeight: FontWeight.bold),
                  )
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Flutter plugin to get access to data that is globally available in any BlackBerry Dynamics Application.

Homepage

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, flutter_plugin_bbd_base

More

Packages that depend on flutter_plugin_bbd_application