flutter_push_devonics 1.0.5 flutter_push_devonics: ^1.0.5 copied to clipboard
Push Devonics Flutter Plugin
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_push_devonics/flutter_push_devonics.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 _userID = 'Empty';
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
FlutterPushDevonics.init("APP_ID");
FlutterPushDevonics.sendTag("TEST", "VALUE TEST");
String userID = await FlutterPushDevonics.getUserID ?? 'Empty User ID';
// 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(() {
_userID = userID;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('PUSH DEVONICS'),
),
body: Center(
child: Text('PUSH USER ID: $_userID\n'),
),
),
);
}
}