-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert image from an https:// url #38
Comments
Short answer is: yes. Note I'd recommend using latest version from master branch for the following. You'd need to implement your own abstract class ZefyrImageDelegate<S> {
/// Builds image widget for specified [imageSource] and [context].
Widget buildImage(BuildContext context, String imageSource);
/// Picks an image from specified [source].
///
/// Returns unique string key for the selected image. Returned key is stored
/// in the document.
Future<String> pickImage(S source);
} There is default implementation which only handles local class ZefyrDefaultImageDelegate implements ZefyrImageDelegate<ImageSource> {
@override
Widget buildImage(BuildContext context, String imageSource) {
final file = new File.fromUri(Uri.parse(imageSource));
final image = new FileImage(file);
return new Image(image: image);
}
@override
Future<String> pickImage(ImageSource source) async {
final file = await ImagePicker.pickImage(source: source);
if (file == null) return null;
return file.uri.toString();
}
} As you can see it uses Now, the main thing to know here is how image information is stored in produced Delta. In short,
You can have more complex flows here as well. For instance, in my project I use Firebase Storage to upload images. When user picks a new image I return unique ID of that image generated by Firebase Storage. Then in Hope this helps. |
thank you! |
Is it possible to give image source as an https url? Something like this:
[{"insert":"","attributes":{"embed":{"type":"image","source":"https://random_image.jpg"}}},{"insert":"\n"}]
The text was updated successfully, but these errors were encountered: