hy_channel_info 2.0.1 copy "hy_channel_info: ^2.0.1" to clipboard
hy_channel_info: ^2.0.1 copied to clipboard

PlatformAndroidiOS
outdated

get app channel info.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  String? _channel;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initChannelState() async {
    String? channelInfo;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      channelInfo = await HyChannelInfo.channelInfo;
    } on PlatformException {
      channelInfo = '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(() {
      _channel = channelInfo;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: ${_channel ?? 'Unknown'}\n'),
        ),
      ),
    );
  }
}
0
likes
100
pub points
34%
popularity

Publisher

unverified uploader

get app channel info.

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on hy_channel_info