flutter_quill_extensions: replace gallery_saver with gal (#1403)

pull/1407/head
santiagos01 2 years ago committed by GitHub
parent a39f45e0c7
commit 225a54a1ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      example/macos/Flutter/GeneratedPluginRegistrant.swift
  2. 3
      example/windows/flutter/generated_plugin_registrant.cc
  3. 1
      example/windows/flutter/generated_plugins.cmake
  4. 35
      flutter_quill_extensions/lib/embeds/builders.dart
  5. 3
      flutter_quill_extensions/pubspec.yaml

@ -7,6 +7,7 @@ import Foundation
import device_info_plus
import file_selector_macos
import gal
import pasteboard
import path_provider_foundation
import url_launcher_macos
@ -14,6 +15,7 @@ import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
GalPlugin.register(with: registry.registrar(forPlugin: "GalPlugin"))
PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))

@ -7,12 +7,15 @@
#include "generated_plugin_registrant.h"
#include <file_selector_windows/file_selector_windows.h>
#include <gal/gal_plugin_c_api.h>
#include <pasteboard/pasteboard_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
GalPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GalPluginCApi"));
PasteboardPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PasteboardPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
file_selector_windows
gal
pasteboard
url_launcher_windows
)

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -5,7 +7,8 @@ import 'package:flutter/services.dart';
import 'package:flutter_quill/extensions.dart' as base;
import 'package:flutter_quill/flutter_quill.dart' hide Text;
import 'package:flutter_quill/translations.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:gal/gal.dart';
import 'package:http/http.dart' as http;
import 'package:math_keyboard/math_keyboard.dart';
import 'package:universal_html/html.dart' as html;
@ -266,13 +269,31 @@ Widget _menuOptionsForReadonlyImage(
icon: Icons.save,
color: Colors.greenAccent,
text: 'Save'.i18n,
onPressed: () {
onPressed: () async {
imageUrl = appendFileExtensionToImageUrl(imageUrl);
GallerySaver.saveImage(imageUrl).then((_) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Saved'.i18n)));
Navigator.pop(context);
});
// Download image
final uri = Uri.parse(imageUrl);
final response = await http.get(uri);
if (response.statusCode != 200) {
throw Exception(
'failed to download image: ${response.statusCode}',
);
}
// Save image to a temporary path
final fileName = uri.pathSegments.isEmpty ? 'image.jpg'
: uri.pathSegments.last;
final imagePath = '${Directory.systemTemp.path}/menu-opt-$fileName';
final imageFile = File(imagePath);
await imageFile.writeAsBytes(response.bodyBytes);
// Save image to gallery
await Gal.putImage(imagePath);
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Saved'.i18n)));
Navigator.pop(context);
},
);
final zoomOption = _SimpleDialogItem(

@ -14,11 +14,12 @@ dependencies:
flutter_quill: ^7.2.19
http: ^1.1.0
image_picker: ">=0.8.5 <2.0.0"
photo_view: ^0.14.0
video_player: ^2.7.0
youtube_player_flutter: ^8.1.1
gallery_saver: ^2.3.2
gal: ^2.1.1
math_keyboard: ">=0.1.8 <0.3.0"
string_validator: ^1.0.0
universal_html: ^2.2.1

Loading…
Cancel
Save