I searched in google for how to copy an image to clipboard in flutter but I did not find any useful information. I only found in flutter documentation this:
"ClipboardData class:
Data stored on the system clipboard.
The system clipboard can contain data of various media types. This data structure currently supports only plain text data, in the text property."
https://api.flutter.dev/flutter/services/ClipboardData-class.html
Is it impossible to copy an image to clipboard in flutter right now?
I did not try and not sure if the answer is you looking for but you can give a try that first you can convert your image to Uint8List format with BASE64 decode and encode then copy it. for conversion you can check this. link
how-to-convert-base64-string-into-image-with-flutter
also check answers of this threat
how-to-send-image-through-post-using-json-in-flutter
Related
I am making web application where the user can copy images from their computer and when they want to send that image they can ctrl v on the text field to see the image their sending. I tried this using JS method call I guess it worked but now its giving a lot of problems for including JS on flutter so my question is there way to achieve this using only flutter.
You can copy the path of the image, then display it using the path copied since copy image directly is not that easy and well supported. (check this here).
Another option is to convert the image to Base64, then copy to clipboard and using the data to display the image.
In case it is required to copy the image directly, and you already have a JS function doing it, you can explore the interoperability between JS and Flutter Web using the js package. This article is a good start
To catch the event when the user presses hot key on his keyboard, check this article out. FocusableActionDetector is the widget we can use to detect the keyboard press, and map specific action to it. In this case it's copying the selected picture's path/ Base64 to clipboard.
You can use the pasteboard package:
final imageBytes = await Pasteboard.image;
Since version 0.1.1 it supports this method on the web client. But not the all types of images are supported, at least on the current version.
I am currently using flutter_quill pakage for formatting text. Now I want to store it in firestore /realtime database. I want to retrieve the formatted text as it is and show in my app.
After researching I came across flutter_html which will help me to display html code in my flutter app. This is great but now I also have to store html data to database.
So, how can I store html data to database using flutter_quill or zefyrka or is there any text editor package which will help me to do my objective.
Any new suggestions are also welcomed. I just want to store and retrieve formatted text in firestore/realtime database using flutter.
Perhaps you should try to encode your text in base64 and store the encoded text in cloud firestore. Please decode your encoded text before displaying it in your app.
how to save state in flutter am trying to make a quantity number which is displayed in text widge there is plus and minus button once I go back from the page the quantity becomes zero even though i have made it any other number
Since your use case is simple , it only requires storing the requisite data to JSON or UTF-8 and writing this data to an editable File.
1.Saving data as JSON
The dart:convert library has converters for JSON and UTF-8, as well as support for creating additional converters. JSON is a simple text format for representing structured objects and collections. UTF-8 is a common variable-width encoding that can represent every character in the Unicode character set.
2.Creating and saving to an editable File
The I/O library enables command-line apps to read and write files and browse directories.
You can used the provider package in Flutter to manage your application state.
Here is the link to the provider package and it's documentation.
Provider Package
Provider Documentation
When asking questions on StackOverflow, it's generally preferred to share some code that you have tried.
In your case, it's likely that you need to use setState in your widget somewhere to modify the value of a variable in your widget class. But without seeing your code, it will be difficult to answer completely.
I am experimenting with tinyMCE and a have a few questions. Using their image handler which inserts an image into the textarea. I use echo $_POST['textarea'] to verify it displays properly on a web page, and it does.
Looking at the HTML code in the browser webconsole, I see the image referenced as: <img title="IMG_1908.JPG" src="data:iamge/jpeg;base64,/9j/4s/...>
A few questions:
Is this image reference actually a base64 image and not just a reference link? How can I see this?
Where does this image "file" actually reside?
If I just saved the data represented by $_POST['textarea'] into a database field, would it capture the entire contents in the database so I can just retrieve it and echo it? Should it be a BLOB field?
Thanks in advance!
Answers:
The firefox web console is a little misleading as it truncates the actual Base64 data, making it look like a short reference link, when in fact, it is typically super long showing all the base64 data characters.
Looking at the web browser's page source actually shows the base64 image in it.
Yes, the tinyMCE HTML form textbox named as 'textarea' can be saved using the $_POST['textarea'] global variable, into a mySQL BLOB field, then can retrieve the same field and echo it to display it again. The echo shows the exact same format that was seen in tinyMCE during input.
Okay so I want to load a image from a URL in my app, however this image will need to be updated every month manually, therefore its not practical to have to submit a new update to apple every time the url changes. So does anyone no of a picture/file sharing site that would allow me keep the same URL for the image even when uploading a updated version of the image?
You can just use the same url for the image that you want presented hosted on your domain or a hosting site.
So something like
http://www.mydomain.com/appImage.jpg
That you always call to and always is the address of the relevant image. Basically the URL is just a location that you can store any image at.
Up to my knowledge, in order to achieve this you will need a static URL. So that means you'll have to buy a domain from a hosting service.
Or if not you can use Google Drive for this. But you'll have to do some more coding for this.
Try using Google Drive:
Upload a text file(*.txt) to your Google Drive and get a shareable link. Convert it to a direct download link.
Next save whatever your image as a String (base64); I have attached some interesting coding examples below.
Then give the file link to your app; download the file; read the String(base64) convert it back to image format.
When you want to update the Image convert it to a String; open the Google Drive; edit your file using Drive Notepad (Do not use
Google Docs) and simply save it Ctrl+S.
Useful Links:
Google Drive Direct Link Generator
Convert between UIImage and Base64 string
Converting between Image and Base64 string in iOS
Java BufferedImage to PNG format Base64 String
Convert image to base64 with java
Hope this helps.