Add margins in a png file - flutter

I have a generated png file with a barcode, I need to save the file on the device, can I add margins on the sides to the picture so that the barcode is read correctly

One way to achieve this can be using the screenshot package (that takes a screenshot of the child widget and saves it as a .png file) to take a screenshot of the image widget inside a padding widget. Give the padding the value you want to see as a margin in the image.
Another approach can be generating that barcode in .svg format and modifying its code before saving.
Or give RepaintBoundary a try.

Related

Display .ico or .icon image in flutter

I have an API providing images with .icon format and I would like to display the image on my Flutter app.
you can use image widget for it like bellow
Image.asset("assets/images/home.ico"),
Image.network(
"https://api.hala-on.com/category_images/icons/1672329105.icon"),
i have write these two widgets of image in actions and see the results one is displaying the .ico image from the assets and the other is displaying the image from the link you provided.
see the results
Code for this

How to take screenshot of screen in flutter when using qr code scanner package

I am trying to scan codes using https://pub.dev/packages/qr_code_scanner. But I would also like to take the screenshot of the code being scanned. For this I wrapped the QRView widget with RepaintBoundary widget along with a globalkey for it (reference: https://codesearchonline.com/flutter-screenshot/). But this is generating a black color screenshot and not the actual code scanned. I tried to see if pausing the camera(controller.pauseCamera) would make a difference, but it was of no use. I tested the code on a plain widget which had a textbox and it was able to get the correct screenshot of that. But I am not able to get the scanned code screenshot. It always comes in black color. Any help would be appreciated. I don't want the entire screen screenshot as it has appbar and bottombar.
If you want to show the qr code image to user after the scan in the same scan area simply call controller.stopCamera(); in your _onQRViewCreated method. this will leave the image of the scanned code in view and will look like you took a screenshot.

How to remove builtin padding from Icon

It seems the Icon widget has a built-in padding, but I would like to remove the padding in order to properly align the icon with other widgets on the left side.
As you can see from the screenshot below, the widget itself is perfectly aligned to the left (I wrapped the Icon in a Container with background color just for testing purposes), but the icon has some padding and it looks missaligned.
Is there a possibility to remove this padding?
I just checked the Icon implementation (you can take a look as well) and could not find anything about added padding. I am not 100% certain but I assume the whitespace is from the icon itself.
I have an alternative solution though:
Get the icon in SVG format (you can download Google Icons from Google Fonts
Remove the padding using a SVG editor (you can use Figma Free version)
Add the icon as an asset in your pubspec.yaml
Good luck!

how to add a button on an jpg image in flutter

I have a jpg and a PNG image file, on which I want to add a button, the image is huge, so when we zoom in the image, the image expands, the button should also expand and contract, I've tried everything, but nothing seems to work. any solutions ?
You probably need to use a Stack widget to have your button on top of your image.
You may also need an AnimatedContainer to change the width and height of your button.
If you already tried this solution, can you share with us your code ?

Flutter box decoration in a container

How can I use svg image in a container's box decoration? Seems it only allows the png/jpg files in AssetImage(). I am trying to display two images on top of the background image set through the box decoration. I am trying to dodge the method of stack. So is there a way?
Flutter has no inbuilt support for SVG as of now..
But you can try this package -> https://pub.dev/packages/flutter_svg
final Widget svg = new SvgPicture.asset(
"assets/image.svg",
);
However, I'd recommend not using an SVG, instead convert your image to a png format