Skip to content

Commit

Permalink
feat: Day 12 - 關於頁面(AboutPage)、App 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
BbsonLin committed Sep 9, 2019
1 parent 926af57 commit b2a1166
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
27 changes: 24 additions & 3 deletions lib/pages/about/about.dart
@@ -1,6 +1,20 @@
import "package:flutter/material.dart";
import 'package:package_info/package_info.dart';

class AboutPage extends StatefulWidget {
@override
_AboutPageState createState() => _AboutPageState();
}

class _AboutPageState extends State<AboutPage> {
String appVesion = "0.0.0";

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

class AboutPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -35,8 +49,8 @@ class AboutPage extends StatelessWidget {
Text("gitme reborn",
style: Theme.of(context).textTheme.title),
SizedBox(height: 4.0),
Text("0.0.1",
style: Theme.of(context).textTheme.subtitle),
Text(appVesion,
style: Theme.of(context).textTheme.subtitle),
],
),
Column(
Expand All @@ -56,4 +70,11 @@ class AboutPage extends StatelessWidget {
),
);
}

Future fetchAppVersion() async {
PackageInfo pacakgeInfo = await PackageInfo.fromPlatform();
setState(() {
appVesion = pacakgeInfo.version;
});
}
}
8 changes: 8 additions & 0 deletions pubspec.lock
Expand Up @@ -67,6 +67,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
package_info:
dependency: "direct main"
description:
name: package_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0+6"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -151,3 +158,4 @@ packages:
version: "2.0.8"
sdks:
dart: ">=2.2.2 <3.0.0"
flutter: ">=1.5.0 <2.0.0"
3 changes: 2 additions & 1 deletion pubspec.yaml
Expand Up @@ -11,7 +11,7 @@ description: A new Flutter project.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
version: 0.0.1

environment:
sdk: ">=2.1.0 <3.0.0"
Expand All @@ -25,6 +25,7 @@ dependencies:
cupertino_icons: ^0.1.2

flutter_progress_hud: ^1.0.2
package_info: ^0.4.0+6

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit b2a1166

Please sign in to comment.