Skip to content

Commit e26e46b

Browse files
committed
🚀 Display current version in example
1 parent 34b8e43 commit e26e46b

File tree

5 files changed

+63
-76
lines changed

5 files changed

+63
-76
lines changed

example/lib/constants/resource.dart

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/lib/main.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:flutter/material.dart';
66
import 'package:flutter/services.dart';
77
import 'package:flutter_localizations/flutter_localizations.dart';
8+
import 'package:package_info_plus/package_info_plus.dart';
89
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
910

1011
import 'constants/extensions.dart';
@@ -15,6 +16,8 @@ const Color themeColor = Color(0xff00bc56);
1516

1617
bool get currentIsDark => Screens.mediaQuery.platformBrightness.isDark;
1718

19+
PackageInfo? packageInfo;
20+
1821
void main() {
1922
runApp(MyApp());
2023
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(

example/lib/pages/home_page.dart

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import 'package:flutter/material.dart';
66
import 'package:flutter/services.dart';
77

88
import '../constants/extensions.dart';
9-
import '../constants/resource.dart';
109
import '../constants/screens.dart';
11-
1210
import '../customs/custom_picker_page.dart';
11+
import '../main.dart';
1312
import 'multi_assets_page.dart';
1413
import 'single_assets_page.dart';
1514

@@ -51,43 +50,43 @@ class _HomePageState extends State<HomePage> {
5150
}
5251
}
5352

54-
Widget get header => Container(
55-
margin: const EdgeInsetsDirectional.only(top: 30.0),
56-
height: 60.0,
57-
child: Row(
58-
mainAxisAlignment: MainAxisAlignment.center,
59-
children: <Widget>[
60-
AspectRatio(
61-
aspectRatio: 1.0,
62-
child: Hero(
63-
tag: 'LOGO',
64-
child: Image.asset(
65-
R.ASSETS_FLUTTER_CANDIES_LOGO_PNG,
66-
),
67-
),
53+
Widget get header {
54+
return Container(
55+
margin: const EdgeInsetsDirectional.only(top: 30.0),
56+
height: 60.0,
57+
child: Row(
58+
mainAxisAlignment: MainAxisAlignment.center,
59+
children: <Widget>[
60+
AspectRatio(
61+
aspectRatio: 1.0,
62+
child: Hero(
63+
tag: 'LOGO',
64+
child: Image.asset('assets/flutter_candies_logo.png'),
6865
),
69-
const SizedBox(width: 10.0),
70-
Column(
71-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
72-
crossAxisAlignment: CrossAxisAlignment.start,
73-
children: <Widget>[
74-
const Text(
75-
'WeChat Asset Picker',
76-
style: TextStyle(
77-
fontSize: 18.0,
78-
fontWeight: FontWeight.bold,
79-
),
80-
),
81-
Text(
82-
'Demo for the package.',
83-
style: context.themeData.textTheme.caption,
66+
),
67+
const SizedBox(width: 10.0),
68+
Column(
69+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
70+
crossAxisAlignment: CrossAxisAlignment.start,
71+
children: <Widget>[
72+
const Text(
73+
'WeChat Asset Picker',
74+
style: TextStyle(
75+
fontSize: 18.0,
76+
fontWeight: FontWeight.bold,
8477
),
85-
],
86-
),
87-
const SizedBox(width: 20.0),
88-
],
89-
),
90-
);
78+
),
79+
Text(
80+
packageInfo == null ? 'Unknown version' : packageInfo!.version,
81+
style: context.themeData.textTheme.caption,
82+
),
83+
],
84+
),
85+
const SizedBox(width: 20.0),
86+
],
87+
),
88+
);
89+
}
9190

9291
@override
9392
Widget build(BuildContext context) {

example/lib/pages/splash_page.dart

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/// [Date] 2020-05-31 21:36
44
///
55
import 'package:flutter/material.dart';
6-
import 'package:flutter/scheduler.dart';
6+
import 'package:package_info_plus/package_info_plus.dart';
77

88
import '../constants/extensions.dart';
9-
import '../constants/resource.dart';
9+
import '../main.dart';
1010
import 'home_page.dart';
1111

1212
class SplashPage extends StatefulWidget {
@@ -20,32 +20,25 @@ class _SplashPageState extends State<SplashPage> {
2020
@override
2121
void initState() {
2222
super.initState();
23-
SchedulerBinding.instance?.addPostFrameCallback(
24-
(Duration _) {
25-
Future<void>.delayed(
26-
const Duration(seconds: 2),
27-
() {
28-
Navigator.of(context).pushReplacement(
29-
PageRouteBuilder<void>(
30-
pageBuilder: (_, __, ___) => const HomePage(),
31-
transitionsBuilder: (
32-
_,
33-
Animation<double> animation,
34-
Animation<double> secondaryAnimation,
35-
Widget child,
36-
) {
37-
return FadeTransition(
38-
opacity: animation,
39-
child: child,
40-
);
41-
},
42-
transitionDuration: const Duration(seconds: 1),
43-
),
44-
);
23+
init();
24+
}
25+
26+
Future<void> init() async {
27+
await PackageInfo.fromPlatform()
28+
.then((PackageInfo p) => packageInfo = p)
29+
.catchError((Object _) {});
30+
await Future<void>.delayed(const Duration(seconds: 2));
31+
if (mounted) {
32+
Navigator.of(context).pushReplacement(
33+
PageRouteBuilder<void>(
34+
pageBuilder: (_, __, ___) => const HomePage(),
35+
transitionsBuilder: (_, Animation<double> a, __, Widget child) {
36+
return FadeTransition(opacity: a, child: child);
4537
},
46-
);
47-
},
48-
);
38+
transitionDuration: const Duration(seconds: 1),
39+
),
40+
);
41+
}
4942
}
5043

5144
@override
@@ -55,10 +48,7 @@ class _SplashPageState extends State<SplashPage> {
5548
child: Center(
5649
child: Hero(
5750
tag: 'LOGO',
58-
child: Image.asset(
59-
R.ASSETS_FLUTTER_CANDIES_LOGO_PNG,
60-
width: 150.0,
61-
),
51+
child: Image.asset('assets/flutter_candies_logo.png', width: 150.0),
6252
),
6353
),
6454
);

example/pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_assets_picker_demo
2-
description: A new Flutter project.
3-
version: 1.0.0+1
2+
description: The demo project for the wechat_assets_picker package.
3+
version: 6.0.0-dev.1
44
publish_to: none
55

66
environment:
@@ -18,6 +18,7 @@ dependencies:
1818
wechat_camera_picker: ^2.1.0
1919

2020
extended_image: ^4.0.0
21+
package_info_plus: ^1.0.3
2122
path: ^1.8.0
2223
path_provider: ^2.0.1
2324
provider: ^5.0.0

0 commit comments

Comments
 (0)