redlink_flutter_sdk 1.0.0-dev.1 copy "redlink_flutter_sdk: ^1.0.0-dev.1" to clipboard
redlink_flutter_sdk: ^1.0.0-dev.1 copied to clipboard

outdated

Flutter plugin for Redlink

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:redlink_flutter_sdk/redlink_messaging.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool didConfigureSDK = false;
  RedlinkMessaging sdk = RedlinkMessaging();
  String token;
  Map<String, dynamic> _pushMessage;

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

  initRedlinkSDK() {
    sdk.configure(onMessage: (message) {
      setState(() {
        _pushMessage = message;
      });
    });
    sdk.getToken().asStream().listen((event) {
      setState(() {
        token = event;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            SizedBox(
              height: 50,
            ),
            Text(
              'Push token:',
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
              child: Center(
                child: token != null ? SelectableText('$token') : Text('Waiting for token request to complete'),
              ),
            ),
            SizedBox(
              height: 50,
            ),
            Text(
              'Push notification:',
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
              child: Center(
                child: Text(_pushMessage != null ? '$_pushMessage' : 'Waiting for push notification'),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
0
pub points
2%
popularity

Publisher

verified publisherflutter.redlink.pl

Flutter plugin for Redlink

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on redlink_flutter_sdk