Skip to content

Commit

Permalink
moving to flutter comm
Browse files Browse the repository at this point in the history
  • Loading branch information
rodydavis committed May 24, 2019
1 parent 1ab09be commit 4d2d992
Show file tree
Hide file tree
Showing 10 changed files with 352 additions and 93 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 0.1.0 - 04.06.2019

* Making Example Desktop Aware

## [0.0.8] - Updating Dependencies

* Updating Kotlin Version

## [0.0.7] - Refactor

* Updating Example

## [0.0.6] - Refactor

* Updating Example

## [0.0.5] - Dart Support

* Dart 2.1.0 support
Expand Down
231 changes: 230 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,232 @@
[![Buy Me A Coffee](https://img.shields.io/badge/Donate-Buy%20Me%20A%20Coffee-yellow.svg)](https://www.buymeacoffee.com/rodydavis)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WSH3GVC49GNNJ)

# get_version
![alt text](https://github.com/AppleEducate/get_version/blob/master/screenshots/IMG_0023.PNG)

## Description
Get the Version Name, Version Code and App ID on iOS and Android.

## Setup
### Android

Go to build.gradle and update:

```
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
```

### iOS

Already good to go.

## How to Use

Get OS Version:

```
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
platformVersion = await GetVersion.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
```

Get Version Name:

```
String projectVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectVersion = await GetVersion.projectVersion;
} on PlatformException {
projectVersion = 'Failed to get project version.';
}
```

Get Version Code:

```
String projectCode;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectCode = await GetVersion.projectCode;
} on PlatformException {
projectCode = 'Failed to get build number.';
}
```

Get App ID:

```
String projectAppID;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectAppID = await GetVersion.appID;
} on PlatformException {
projectAppID = 'Failed to get app ID.';
}
```

Get App Name:

```
String projectName;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectName = await GetVersion.appName;
} on PlatformException {
projectName = 'Failed to get app name.';
}
```

## Example

```
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get_version/get_version.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
String _projectVersion = '';
String _projectCode = '';
String _projectAppID = '';
String _projectName = '';
@override
initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
platformVersion = await GetVersion.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
String projectVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectVersion = await GetVersion.projectVersion;
} on PlatformException {
projectVersion = 'Failed to get project version.';
}
String projectCode;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectCode = await GetVersion.projectCode;
} on PlatformException {
projectCode = 'Failed to get build number.';
}
String projectAppID;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectAppID = await GetVersion.appID;
} on PlatformException {
projectAppID = 'Failed to get app ID.';
}
String projectName;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
projectName = await GetVersion.appName;
} on PlatformException {
projectName = 'Failed to get app name.';
}
// 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(() {
_platformVersion = platformVersion;
_projectVersion = projectVersion;
_projectCode = projectCode;
_projectAppID = projectAppID;
_projectName = projectName;
});
}
<h3 align="center">The <i>get_version<i> plugin was moved to <a href='https://github.com/AppleEducate/plugins'>plugins/packages/get_version</a></h3>
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Plugin example app'),
),
body: new SingleChildScrollView(
child: new ListBody(
children: <Widget>[
new Container(
height: 10.0,
),
new ListTile(
leading: new Icon(Icons.info),
title: const Text('Name'),
subtitle: new Text(_projectName),
),
new Container(
height: 10.0,
),
new ListTile(
leading: new Icon(Icons.info),
title: const Text('Running on'),
subtitle: new Text(_platformVersion),
),
new Divider(
height: 20.0,
),
new ListTile(
leading: new Icon(Icons.info),
title: const Text('Version Name'),
subtitle: new Text(_projectVersion),
),
new Divider(
height: 20.0,
),
new ListTile(
leading: new Icon(Icons.info),
title: const Text('Version Code'),
subtitle: new Text(_projectCode),
),
new Divider(
height: 20.0,
),
new ListTile(
leading: new Icon(Icons.info),
title: const Text('App ID'),
subtitle: new Text(_projectAppID),
),
],
),
),
),
);
}
}
```
36 changes: 28 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
group 'com.appleeducate.getversion'
version '1.0-SNAPSHOT'

version '1.0'

buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10"
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

Expand All @@ -26,22 +24,44 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27
compileSdkVersion 28

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
debug {

}
profile {
// Specifies a sorted list of fallback build types that the
// plugin should try to use when a dependency does not include a
// "staging" build type. You may specify as many fallbacks as you
// like, and the plugin selects the first build type that's
// available in the dependency.
//matchingFallbacks = ['debug', 'release']
}
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
api 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.20'
}

apply plugin: 'kotlin-android-extensions'
23 changes: 16 additions & 7 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
localPropertiesFile.withInputStream { stream ->
localProperties.load(stream)
}
}

Expand Down Expand Up @@ -42,6 +43,17 @@ android {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
debug {

}
profile {
// Specifies a sorted list of fallback build types that the
// plugin should try to use when a dependency does not include a
// "staging" build type. You may specify as many fallbacks as you
// like, and the plugin selects the first build type that's
// available in the dependency.
//matchingFallbacks = ['debug', 'release']
}
}
}

Expand All @@ -50,8 +62,5 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
api 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.20'
}
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.1.51'
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
4 changes: 3 additions & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
4 changes: 2 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Thu Feb 07 11:51:55 EST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
Loading

0 comments on commit 4d2d992

Please sign in to comment.