Skip to content

Commit b66a6b7

Browse files
committed
feat: check update script
1 parent 2886825 commit b66a6b7

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/widgets/dialogs/show_release_dialog.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,20 @@ class ReleaseDialog extends HookWidget {
2828
Widget build(BuildContext context) {
2929
final t = getLocalizations(context);
3030

31+
final updateScriptIsExists = useState(false);
32+
33+
useEffect(() {
34+
if (isWindows) {
35+
String resolvedExecutablePath = Platform.resolvedExecutable;
36+
String path = p.dirname(resolvedExecutablePath);
37+
String batFilePath = p.join(path, 'iris-updater.bat');
38+
updateScriptIsExists.value = File(batFilePath).existsSync();
39+
}
40+
return null;
41+
}, []);
42+
3143
void update() async {
32-
if (Platform.isWindows) {
44+
if (isWindows) {
3345
String resolvedExecutablePath = Platform.resolvedExecutable;
3446
String path = p.dirname(resolvedExecutablePath);
3547
String batFilePath = p.join(path, 'iris-updater.bat');
@@ -81,7 +93,7 @@ class ReleaseDialog extends HookWidget {
8193
// ),
8294
// ),
8395
Visibility(
84-
visible: isDesktop,
96+
visible: isDesktop && updateScriptIsExists.value,
8597
child: TextButton(
8698
onPressed: update,
8799
child: Text(

0 commit comments

Comments
 (0)