From 0ea8da0d44fa7d33f4e07df539219677403ae61b Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Fri, 23 Jul 2021 00:42:28 +0200 Subject: [PATCH] Remove a few more cases of dart:io usage I want to abstract out all uses of File and Directory. The sooner I can do that the sooner I can use it on the web. --- lib/apis/github.dart | 2 +- lib/apis/gitlab.dart | 2 +- lib/core/note.dart | 3 ++- lib/screens/note_editor.dart | 5 +---- lib/setup/screens.dart | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/apis/github.dart b/lib/apis/github.dart index 3350c473..2a87666d 100644 --- a/lib/apis/github.dart +++ b/lib/apis/github.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; +import 'dart:io' show HttpHeaders; import 'package:flutter/foundation.dart' as foundation; import 'package:flutter/services.dart'; diff --git a/lib/apis/gitlab.dart b/lib/apis/gitlab.dart index f4487bde..617f6dac 100644 --- a/lib/apis/gitlab.dart +++ b/lib/apis/gitlab.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; +import 'dart:io' show HttpHeaders; import 'dart:math'; import 'package:flutter/foundation.dart' as foundation; diff --git a/lib/core/note.dart b/lib/core/note.dart index b96f85b6..a84c5e6f 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -513,7 +513,8 @@ class Note with NotesNotifier { } } - Future addImageSync(File file) async { + Future addImageSync(String filePath) async { + var file = File(filePath); var absImagePath = _buildImagePath(file); file.copySync(absImagePath); diff --git a/lib/screens/note_editor.dart b/lib/screens/note_editor.dart index 40d4a45a..6147be09 100644 --- a/lib/screens/note_editor.dart +++ b/lib/screens/note_editor.dart @@ -14,8 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -127,8 +125,7 @@ class NoteEditorState extends State with WidgetsBindingObserver { if (existingImages.isNotEmpty) { for (var imagePath in existingImages) { try { - var file = File(imagePath); - note!.addImageSync(file); + note!.addImageSync(imagePath); } catch (e, st) { Log.e("New Note Existing Image", ex: e, stacktrace: st); } diff --git a/lib/setup/screens.dart b/lib/setup/screens.dart index 3533f802..763403e6 100644 --- a/lib/setup/screens.dart +++ b/lib/setup/screens.dart @@ -1,4 +1,4 @@ -import 'dart:io'; +import 'dart:io' show Platform, Directory; import 'package:flutter/material.dart'; import 'package:flutter/services.dart';