app_info 0.0.1 app_info: ^0.0.1 copied to clipboard
AppInfo flutter plugin.
import 'dart:async';
import 'package:app_info/app_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
print("init state ...");
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
String r;
try {
r = await AppInfo.platformVersion;
r += "|" + await AppInfo.appId;
r += "|" + await AppInfo.udid;
r += "|" + await AppInfo.model;
r += "|" + await AppInfo.appVerName;
r += "|" + (await AppInfo.appVerCode).toString();
r += "|" + await AppInfo.appChannel;
} on PlatformException {
r = 'Failed to get platform version.';
}
if (!mounted) return;
setState(() {
_platformVersion = r;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
),
);
}
}