xeno_flutter_android 0.1.0 copy "xeno_flutter_android: ^0.1.0" to clipboard
xeno_flutter_android: ^0.1.0 copied to clipboard

PlatformAndroid

Android implementation of xeno_sdk.

example/lib/main.dart

import 'dart:async';

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  bool? _hasNotificationPermission;
  final _xenoSdkAndroid = XenoFlutterAndroid();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      _hasNotificationPermission =
          await _xenoSdkAndroid.hasNotificationPermission();
    } on Exception catch (e) {
      _hasNotificationPermission = null;
      debugPrint('Failed to get notification permission. $e');
    }

    // 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(() {});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Xeno Flutter Example'),
        ),
        body: Center(
          child: Text(
              'Has Notification Permission: [ $_hasNotificationPermission ]'),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            initPlatformState();
          },
          tooltip: 'Request Notification Permission',
          child: const Icon(Icons.notifications),
        ),
      ),
    );
  }
}
2
likes
130
points
339
downloads

Publisher

unverified uploader

Weekly Downloads

Android implementation of xeno_sdk.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter, xeno_flutter_platform_interface

More

Packages that depend on xeno_flutter_android