@@ -13,15 +13,11 @@ const String _actionsRunUrl =
13
13
const String _openIssueUrl = '${environment .repoUrl }/issues/new/choose' ;
14
14
15
15
class VersionInfoItem extends StatelessWidget {
16
- const VersionInfoItem (
17
- {super .key,
18
- required this .linkUrl,
19
- required this .linkText,
20
- this .itemLabel});
16
+ const VersionInfoItem ({super .key, this .label, required this .value, this .url});
21
17
22
- final String ? itemLabel ;
23
- final String linkUrl ;
24
- final String linkText ;
18
+ final String ? label ;
19
+ final String value ;
20
+ final String ? url ;
25
21
26
22
Future <void > _launchUrl (String url) async {
27
23
if (! await launchUrl (Uri .parse (url),
@@ -34,14 +30,18 @@ class VersionInfoItem extends StatelessWidget {
34
30
Widget build (BuildContext context) {
35
31
return Text .rich (
36
32
TextSpan (children: [
37
- if (itemLabel != null ) TextSpan (text: itemLabel ),
33
+ if (label != null ) TextSpan (text: label ),
38
34
TextSpan (
39
- text: linkText,
40
- style: TextStyle (color: Theme .of (context).colorScheme.primary),
41
- recognizer: TapGestureRecognizer ()
42
- ..onTap = () async {
43
- _launchUrl (linkUrl);
44
- })
35
+ text: value,
36
+ style: url != null
37
+ ? TextStyle (color: Theme .of (context).colorScheme.primary)
38
+ : null ,
39
+ recognizer: url != null
40
+ ? (TapGestureRecognizer ()
41
+ ..onTap = () async {
42
+ _launchUrl (url! );
43
+ })
44
+ : null )
45
45
]),
46
46
textAlign: TextAlign .center,
47
47
);
@@ -57,28 +57,27 @@ class VersionInfo extends StatelessWidget {
57
57
Widget build (BuildContext context) {
58
58
return Wrap (alignment: WrapAlignment .center, children: [
59
59
VersionInfoItem (
60
- itemLabel : '©${DateTime .now ().year .toString ()} ${locale .title } ' ,
61
- linkText : 'v${environment .version }' ,
62
- linkUrl : _releaseUrl,
60
+ label : '©${DateTime .now ().year .toString ()} ${locale .title } ' ,
61
+ value : 'v${environment .version }' ,
62
+ url : _releaseUrl,
63
63
),
64
64
_divider,
65
65
const VersionInfoItem (
66
- itemLabel: '${locale .labelBuildNumber }: ' ,
67
- linkText: environment.buildNumber,
68
- linkUrl: _actionsRunUrl,
66
+ label: '${locale .labelBuildNumber }: ' ,
67
+ value: environment.buildNumber,
69
68
),
70
69
_divider,
71
70
VersionInfoItem (
72
- itemLabel : '${locale .labelCommit }: ' ,
73
- linkText : environment.commitSha.length > 7
71
+ label : '${locale .labelCommit }: ' ,
72
+ value : environment.commitSha.length > 7
74
73
? environment.commitSha.substring (0 , 7 )
75
74
: environment.commitSha,
76
- linkUrl : _commitUrl,
75
+ url : _commitUrl,
77
76
),
78
77
_divider,
79
78
const VersionInfoItem (
80
- linkText : locale.reportIssue,
81
- linkUrl : _openIssueUrl,
79
+ value : locale.reportIssue,
80
+ url : _openIssueUrl,
82
81
)
83
82
]);
84
83
}
0 commit comments