Change the image pick callback function

pull/44/head
ArjanAswal 4 years ago
parent 89ec5e8427
commit 23ae3e3ec2
  1. 20
      app/lib/pages/home_page.dart
  2. 84
      app/pubspec.lock
  3. 1
      app/pubspec.yaml

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:path/path.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -10,6 +11,7 @@ import 'package:flutter_quill/widgets/controller.dart';
import 'package:flutter_quill/widgets/default_styles.dart'; import 'package:flutter_quill/widgets/default_styles.dart';
import 'package:flutter_quill/widgets/editor.dart'; import 'package:flutter_quill/widgets/editor.dart';
import 'package:flutter_quill/widgets/toolbar.dart'; import 'package:flutter_quill/widgets/toolbar.dart';
import 'package:path_provider/path_provider.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import 'read_only_page.dart'; import 'read_only_page.dart';
@ -125,19 +127,21 @@ class _HomePageState extends State<HomePage> {
Container( Container(
child: QuillToolbar.basic( child: QuillToolbar.basic(
controller: _controller, controller: _controller,
onImagePickCallback: _fakeUploadImageCallBack), onImagePickCallback: _onImagePickCallback),
) )
], ],
); );
} }
/// Upload the image file to AWS s3 when image is picked // Renders the image picked by imagePicker from local file storage
Future<String> _fakeUploadImageCallBack(File file) async { // You can also upload the picked image to any server (eg : AWS s3 or Firebase) and then return the uploaded image URL
print(file); Future<String> _onImagePickCallback(File file) async {
var completer = new Completer<String>(); if (file == null) return null;
completer.complete( // Copies the picked file from temporary cache to applications directory
'https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png'); Directory appDocDir = await getApplicationDocumentsDirectory();
return completer.future; File copiedFile =
await file.copy('${appDocDir.path}/${basename(file.path)}');
return copiedFile.path.toString();
} }
Widget _buildMenuBar(BuildContext context) { Widget _buildMenuBar(BuildContext context) {

@ -78,6 +78,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0-nullsafety.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -149,6 +163,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -170,6 +191,41 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.8.0-nullsafety.1"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.27"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+2"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+8"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+3"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@ -184,6 +240,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.10.3" version: "0.10.3"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -191,6 +254,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.3" version: "1.0.3"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.13"
quill_delta: quill_delta:
dependency: transitive dependency: transitive
description: description:
@ -336,6 +406,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.3" version: "2.1.0-nullsafety.3"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.4+1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
zone_local: zone_local:
dependency: transitive dependency: transitive
description: description:

@ -28,6 +28,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0 cupertino_icons: ^1.0.0
path_provider: ^1.6.27
flutter_quill: flutter_quill:
path: ../ path: ../

Loading…
Cancel
Save