new: PlatformType

This commit is contained in:
lollipopkit
2023-03-13 12:02:48 +08:00
parent 4c4153ef98
commit c2e822f49d
18 changed files with 197 additions and 113 deletions

View File

@@ -416,6 +416,7 @@ class _SettingPageState extends State<SettingPage> {
onPressed: () {
if (_pushToken != null) {
copy(_pushToken!);
showSnackBar(context, Text(_s.success));
} else {
showSnackBar(context, Text(_s.getPushTokenFailed));
}
@@ -424,15 +425,26 @@ class _SettingPageState extends State<SettingPage> {
subtitle: FutureBuilder<String?>(
future: getToken(),
builder: (context, snapshot) {
if (snapshot.hasData) {
_pushToken = snapshot.data;
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return const Text('Getting Token...');
default:
var text = _pushToken;
if (snapshot.hasError) {
text = 'Error: ${snapshot.error}';
}
_pushToken = snapshot.data;
if (_pushToken == null) {
text = 'Null token';
}
return Text(
text!,
style: grey,
overflow: TextOverflow.ellipsis,
maxLines: 1,
);
}
return Text(
_pushToken ?? 'Getting Token...',
style: grey,
overflow: TextOverflow.ellipsis,
maxLines: 1,
);
},
),
);