Skip to content

Commit

Permalink
Added deps
Browse files Browse the repository at this point in the history
  • Loading branch information
deathblade666 committed Aug 30, 2024
1 parent 2e737ac commit d49e55d
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 19 deletions.
35 changes: 17 additions & 18 deletions lib/pages/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import 'dart:convert';
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:file_saver/file_saver.dart';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mdeditor/main.dart';
import 'package:shared_preferences/shared_preferences.dart';

enum menuItems {
Expand Down Expand Up @@ -105,31 +107,28 @@ class Menu extends StatefulWidget {
PopupMenuItem<menuItems>(
value: menuItems.save,
onTap: () async {
List<int> list = utf8.encode(openFile.text);
//Uint8List bytes = utf8.encode(openFile.text);
Uint8List bytes = Uint8List.fromList(list);
var file = File('/sdcard/mdeditor/test files/test58.md');
//final outputfile = await FileSaver.instance.saveAs(
// ext: "md",
//name: "test58",
// file: file,
// mimeType: MimeType.custom,
// customMimeType: 'text/markdown',
// );

Uint8List bytes = utf8.encode(openFile.text);
//var file = File('/sdcard/mdeditor/test files/test58.md');
final FileSaveLocation? result =
await getSaveLocation(suggestedName: "fileName");
if (result == null) {
// Operation was canceled by the user.
return;
}

final XFile textfile = XFile.fromData(bytes);
await textfile.saveTo(result.path);
String path = result.path;
//var file = File(outputfile!);
var sink = file.openWrite();
sink.add(bytes);
//sink.write(openFile.text);
//file.writeAsString(openFile.text);

//var sink = file.openWrite();
//sink.add(bytes);

showDialog(
context: context,
builder: (BuildContext context){
return AlertDialog(
title: const Text("Success"),
content: Text("Save successfully to "),
content: Text("Save successfully to $path"),
);
}
);
Expand Down
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <dynamic_color/dynamic_color_plugin.h>
#include <file_saver/file_saver_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) dynamic_color_registrar =
Expand All @@ -16,4 +17,7 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_saver_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSaverPlugin");
file_saver_plugin_register_with_registrar(file_saver_registrar);
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
}
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
dynamic_color
file_saver
file_selector_linux
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import Foundation

import dynamic_color
import file_saver
import file_selector_macos
import path_provider_foundation
import shared_preferences_foundation

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
}
74 changes: 73 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.14"
file_selector:
dependency: "direct main"
description:
name: file_selector
sha256: "5019692b593455127794d5718304ff1ae15447dea286cdda9f0db2a796a1b828"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
file_selector_android:
dependency: transitive
description:
name: file_selector_android
sha256: b8c9717a0177ca6fa035554b82cd6c83b838ddc66b7704eb6df0f77f027ecc90
url: "https://pub.dev"
source: hosted
version: "0.5.1+7"
file_selector_ios:
dependency: transitive
description:
name: file_selector_ios
sha256: "38ebf91ecbcfa89a9639a0854ccaed8ab370c75678938eebca7d34184296f0bb"
url: "https://pub.dev"
source: hosted
version: "0.5.3"
file_selector_linux:
dependency: transitive
description:
name: file_selector_linux
sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492"
url: "https://pub.dev"
source: hosted
version: "0.9.2+1"
file_selector_macos:
dependency: transitive
description:
name: file_selector_macos
sha256: f42eacb83b318e183b1ae24eead1373ab1334084404c8c16e0354f9a3e55d385
url: "https://pub.dev"
source: hosted
version: "0.9.4"
file_selector_platform_interface:
dependency: transitive
description:
name: file_selector_platform_interface
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
url: "https://pub.dev"
source: hosted
version: "2.6.2"
file_selector_web:
dependency: transitive
description:
name: file_selector_web
sha256: c4c0ea4224d97a60a7067eca0c8fd419e708ff830e0c83b11a48faf566cec3e7
url: "https://pub.dev"
source: hosted
version: "0.9.4+2"
file_selector_windows:
dependency: transitive
description:
name: file_selector_windows
sha256: "2ad726953f6e8affbc4df8dc78b77c3b4a060967a291e528ef72ae846c60fb69"
url: "https://pub.dev"
source: hosted
version: "0.9.3+2"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -184,6 +248,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "10.7.0"
http:
dependency: transitive
description:
name: http
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev"
source: hosted
version: "1.2.2"
http_parser:
dependency: transitive
description:
Expand Down Expand Up @@ -495,4 +567,4 @@ packages:
version: "1.0.4"
sdks:
dart: ">=3.5.1 <4.0.0"
flutter: ">=3.22.0"
flutter: ">=3.24.0"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies:
markdown_editor_plus: ^0.2.15
dynamic_color: 1.6.9
file_picker: ^8.1.2
file_selector: ^1.0.3

dev_dependencies:
flutter_test:
Expand Down
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@

#include <dynamic_color/dynamic_color_plugin_c_api.h>
#include <file_saver/file_saver_plugin.h>
#include <file_selector_windows/file_selector_windows.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
DynamicColorPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
FileSaverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSaverPlugin"));
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
}
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
dynamic_color
file_saver
file_selector_windows
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down

0 comments on commit d49e55d

Please sign in to comment.