Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emekalites/flutter_android_version
Get android version code and name
https://github.com/emekalites/flutter_android_version
Last synced: 4 days ago
JSON representation
Get android version code and name
- Host: GitHub
- URL: https://github.com/emekalites/flutter_android_version
- Owner: emekalites
- License: mit
- Created: 2020-04-26T14:51:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-26T20:40:44.000Z (over 4 years ago)
- Last Synced: 2023-08-20T21:24:51.038Z (over 1 year ago)
- Language: Ruby
- Homepage: https://pub.dev/packages/androidversion
- Size: 65.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Buy Me A Coffee](https://img.shields.io/badge/Donate-Buy%20Me%20A%20Coffee-yellow.svg)](https://www.buymeacoffee.com/emekaihedoro)
# 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:
```dart
Map 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.';
}
```
## Example```dart
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 {
Map _info = {};@override
void initState() {
super.initState();
initPlatformState();
}Future initPlatformState() async {
Map 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'),
),
),
);
}
}```