androidversion

Creator: coderz1093

Last updated:

0 purchases

androidversion Image
androidversion Images

Languages

Categories

Add to Cart

Description:

androidversion

androidversion #
Get android version code and name.
Description #
Get the Android device Version Name, Release Code and Version Code.
How to Use #
Get Android Information:
Map<dynamic, dynamic> androidInfo;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
androidInfo = await AndroidInfo.version;
//expected map {'name': 'P', 'code': 28, 'release': 9}
} on PlatformException {
androidInfo = 'Failed to get platform version.';
}
copied to clipboard
Example #
import 'package:flutter/material.dart';
import 'dart:async';

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

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

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

class _MyAppState extends State<MyApp> {
Map<dynamic, dynamic> _info = {};

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

Future<void> initPlatformState() async {
Map<dynamic, dynamic> info;
try {
info = await AndroidInfo.version;
} on PlatformException {
info = {'error': 'Failed to get platform version.'};
}

if (!mounted) return;

setState(() => _info = info);
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('My App'),
),
body: Center(
child: Text('Running on: $_info\n'),
),
),
);
}
}

copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.