mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-23 16:45:27 +01:00
new: pick from file to add key #9
This commit is contained in:
@@ -249,7 +249,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
),
|
||||
AboutListTile(
|
||||
icon: const Icon(Icons.text_snippet),
|
||||
applicationName: BuildData.name,
|
||||
applicationName: '\n${BuildData.name}',
|
||||
applicationVersion: _versionStr,
|
||||
applicationIcon: _buildIcon(),
|
||||
aboutBoxChildren: [
|
||||
@@ -259,13 +259,12 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
UrlText(
|
||||
text: _s.aboutThanks,
|
||||
),
|
||||
const UrlText(
|
||||
text: rainSunMeGithub,
|
||||
replace: 'RainSunMe',
|
||||
),
|
||||
const UrlText(
|
||||
text: fectureGithub,
|
||||
replace: 'fecture',
|
||||
// Thanks
|
||||
...thanksMap.keys.map(
|
||||
(key) => UrlText(
|
||||
text: thanksMap[key] ?? '',
|
||||
replace: key,
|
||||
),
|
||||
)
|
||||
],
|
||||
child: Text(_s.license),
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -90,6 +93,29 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
enableSuggestions: false,
|
||||
decoration: buildDecoration(_s.privateKey, icon: Icons.vpn_key),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
final result = await FilePicker.platform.pickFiles();
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final path = result.files.single.path;
|
||||
if (path == null) {
|
||||
showSnackBar(context, const Text('path is null'));
|
||||
return;
|
||||
}
|
||||
|
||||
final file = File(path);
|
||||
if (!file.existsSync()) {
|
||||
showSnackBar(context, Text(_s.fileNotExist(path)));
|
||||
return;
|
||||
}
|
||||
|
||||
_keyController.text = await file.readAsString();
|
||||
},
|
||||
child: Text(_s.pickFile),
|
||||
),
|
||||
TextField(
|
||||
controller: _pwdController,
|
||||
autocorrect: false,
|
||||
|
||||
Reference in New Issue
Block a user