fix: CRLF of private key (#7)

This commit is contained in:
lollipopkit
2024-01-14 21:32:32 +08:00
parent 11dca4c37c
commit df800aba70
6 changed files with 37 additions and 35 deletions

View File

@@ -84,7 +84,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
);
}
PreferredSizeWidget _buildAppBar() {
CustomAppBar _buildAppBar() {
final actions = [
IconButton(
tooltip: l10n.delete,
@@ -181,10 +181,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
TextButton(
onPressed: () async {
final path = await pickOneFile();
if (path == null) {
context.showSnackBar(l10n.fieldMustNotEmpty);
return;
}
if (path == null) return;
final file = File(path);
if (!file.existsSync()) {
@@ -203,7 +200,12 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
return;
}
_keyController.text = await file.readAsString();
final content = await file.readAsString();
/// Issue #7
/// Replace all CRLF to LF
content.replaceAll('\r\n', '\n');
_keyController.text = content;
},
child: Text(l10n.pickFile),
),