How to make specific part of image as background Image? - image

How can I make the selected part in the image below as my background image?

You can use alignment property of Image or DecorationImage combined with fit.
Image.network(
'url',
alignment: Alignment.center,
fit: BoxFit.cover,
);

Related

How to fit image into a box of all aspect ratio?

I'm dealing with the template png which has a boxed place where I need to fit any size image within that box. How can fit all dimension image to fit in that box in flutter?. I have attached the image.
I need to add image in that black area which is PNG image and what I tried to implement is here.
body: Stack(
children: [
Positioned(
top: MediaQuery.of(context).size.height / 3.5,
right: MediaQuery.of(context).size.width / 10,
child: imagePicked == null
? SizedBox()
: AspectRatio(
aspectRatio: 1,
child: Image.file(imagePicked, fit: BoxFit.fill),
),
),
const Positioned.fill(
child: Align(
alignment: Alignment.centerRight,
child: Image(image: AssetImage('assets/images/notice.png')))),
],
),
But Here I couldn't manage all dimension images. Please help me sort to fit any dimension image into that black box which is also a template image.
The main issue is here overlaying with stack's widgets.
Widget render prioritize bottom to top level on Stack.
In your code-snippet, place-holder is the bottom widget, and it is being prioritized over the selected image.
That's why putting place-holder as 1st widget on stack solve the issue.

Is there some simple way display any image from folder in flutter?

I was googling but without luck, I found some stackoverflow with making list of images, randomizing it etc but it seems really long process of what I want and I'm thinking If there is some simpler way of doing this.
What I want is, instead of specifying images/image3.jpg. Can I say to display image from a folder called "bluethemedimages" ? - So it will display randomly/any image from this folder. What i want to create is to have 4 different themes, Blue, Yellow, Green, Grey (Each theme will have different coloured images) so later on when the user presses "blue" button it will display any random image from the "bluethemedimages" folder. Below is example of my page and box decoration with the image.
Widget build(BuildContext context) => Container(
//color: Colors.transparent,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/image3.jpg"), fit: BoxFit.cover)),
Thank you so much for help!
Here is a code that I used in my application
Widget build(BuildContext context) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("randomimage"), fit: BoxFit.cover)),)))
onclick(){
var _random = new Random();
setstate((){
randomimage="Bluethemedimage/$(_random.nextInt(no_of_pictures)+1)"}}
name your pictures as 1.png,2.png,3.png and so on

Alternative of ColorFilter in flutter for decorationImage of container

Currently I am using ColorFilter for giving opacity to decoration image of container.
For Image.asset or Image.network we can use like:
Image.network(
'url',
color: Color.fromRGBO(255, 255, 255, 0.5),
colorBlendMode: BlendMode.modulate
),
So is their any such alternative for decorationImage??
Thanks in advance for answer and your valuable time.
ColorFiltered(
colorFilter: ColorFilter.mode(Colors.black.withOpacity(0.2), BlendMode.dstATop),
child: YourWidget(),
)

Card Carousel swipe with details in flutter

I want to create a stack of images with a carousel effect, details of the image will be displayed below in a different container. While swiping an image from the stack, details will be changed with the image.
Already done with the image carousel part and swiping.
CarouselSlider(
viewportFraction: 0.7,
aspectRatio: 1,
autoPlay: true,
enlargeCenterPage: true,
items: carouselList.map(
(image) {
return Container(
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
image:
DecorationImage(image: AssetImage(image), fit: BoxFit.cover),
),
);
},
).toList(),
);
How to change the details of the image while swiping an image from the stack?
Want to achieve a slider like the below image.
Have you checked out this in the package where you can create your own dynamic tree:
CarouselSlider.builder(
itemCount: 15,
itemBuilder: (BuildContext context, int itemIndex) =>
Container(
child: Text(itemIndex.toString()),
),
)
your carouselList will be list of class object where you have the title,release_date , ratings and the image. passing the list to the builder will render the every object up to that length.
Maybe I am late but check this package

How to change RGB configuration of an image in Flutter

I want to put a color filter over an asset image.
As below, I currently have an image with colorBlendMode filter, but I want to be able to directly fix the RGB value of each pixel of the image.
Does anyone know how this can be done?
body: Center(
child: new Image.asset(
'assets/gallery/garrowby_hill.jpg',
width: size.width,
height: size.height,
fit: BoxFit.fill,
color: Color.fromRGBO(redCount, greenCount, blueCount, 1),
colorBlendMode: BlendMode.multiply,
),
),
You can use a ColorFiltered class and use your image as it's child and use colorFilter property ,
TODO:
Wrap your Image.asset in a new Widget called ColorFiltered
add a new property for this widget : colorFilter: ColorFilter.mode(your_color_here, BlendeMode.your_blendMode_here).
You can check those links : ColorFilter Class, colorFilter propery and it's used in this video

Resources