How to setup the 3dots menu inside Image.network in flutter - flutter

I'm looking an example to implement the 3 dots menu inside a picture on my feed of my app... any ideas?
Example

The example in the question is not to use an icon in the photo. Like this:
Column(
children: [
Row(children: [...,Icon()],),
Image.network(),
],
)
But if you want to use icon in the photo, you can use Stack. Like this:
Container(
height: 250,
width: 250,
child: Stack(
children: [
Container(
child: Image.network(
"https://upload.wikimedia.org/wikipedia/commons/e/eb/Ash_Tree_-_geograph.org.uk_-_590710.jpg",
fit: BoxFit.cover,
),
width: MediaQuery.of(context).size.width,
),
Container(
alignment: Alignment.topRight,
child: Icon(
Icons.more_horiz,
color: Colors.white,
),
),
],
),
)

Related

Center-Align one flutter widget in column and position the rest around it

How do I align one widget of a column in the center and put the rest around it?
If I had a Container or so that holds the three input fields and the button and another one that is the box above. How do I align the Container in the middle and put the box in the remaining space without moving the center container?
I tried using Expanded or Flexible but couldnt figure out how to align the widgets in that kind of way.
You can use Column like this:
Column(
children: [
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 40,
width: 40,
color: Colors.yellow,
),
)),
Container(
color: Colors.red,
height: 100,
width: double.infinity,
),
Expanded(
child: Align(
alignment: Alignment.topCenter,
child: Container(
height: 40,
width: 40,
color: Colors.green,
),
)),
],
),

Flutter asset image wont display properly

I want to add an icon to a card widget so I used the ImageIcon widget as below
Card(
color: colorPalette.cultured,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Row(
children: <Widget>[
Text(label,style: TextStyle(fontWeight: FontWeight.w600,fontSize: 15.0,fontFamily: 'Poppins'),),
Spacer(),
ImageIcon(AssetImage('assets/icons/call.png'),),
],
),
),
);
The icon I want to display is,
but what is displayed is,
the assets in the pubspec.yaml are indented properly as well.
Try below Code Hope its help to you . Just change your image on your need
you have add asset image in 2 Ways
Image.assets() - Documentation here
AssetImage()
Row(
children: [
Image(
image: AssetImage('assets/images/shop.png'),
width: 150,
height: 150,
),
Image.asset(
'assets/images/cycle.png',
width: 150,
height: 150,
),
],
),
Your Result Screen ->
You can use either of these for using asset images
Image.asset('image')
or
Image(image: AssetImage('image')) for using asset images
For achieving it with icon
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.blue),
child: Icon(
Icons.call,
color: Colors.white,
),
)

Google Icon(Logo) for Sign_in flutter

I'm trying to add google logo for sign in with google by downloading from https://developers.google.com/identity/branding-guidelines. But when I use it in flutter app, some lines and dots are appearing around logo.
GestureDetector(
child: Container(
padding: EdgeInsets.only(right: _size.height * 0.016),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
// decoration: BoxDecoration(color: Colors.blue),
child: Image.asset(
'assets/images/google_icon/btn_google_light_normal.9.png',
fit: BoxFit.fitWidth,
),
),
SizedBox(
width: 5.0,
),
Text('Sign-in with Google')
],
),
),
),
which results in
enter image description here
or
enter image description here
How to remove glitches around the G logo?
i think there may be problem in the format of image you are using try out this code
Container(
width:300,
height:80,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
// decoration: BoxDecoration(color: Colors.blue),
child:
Image.network(
'http://pngimg.com/uploads/google/google_PNG19635.png',
fit:BoxFit.cover
)
),
SizedBox(
width: 5.0,
),
Text('Sign-in with Google')
],
),
)
You can use an open-source background remover tool such as remove.bg/upload to remove everything around the logo. Then, you can just do the same thing: Image.network('<your path>', height: 40, width: 40) or any size.
Perhaps this is not the most elegant solution, but I just cropped the original image to get rid of the lines.
Before:
After:

Create widget with transparent hole inside

How can I create a semi-transparent background with the transparent hole inside? I tried to use decoration and foreground decorations with different blend modes, stack, ClipRect, colorfilters, but nothing works. I will appreciate any ideas. Thanks!
The "easiest" way I've found to do it is using a ColorFiltered Widget with a Stack.
The following code will create exactly what you need:
#override
Widget build(BuildContext context) {
return Material(
child: Stack(
fit: StackFit.expand,
children: [
Image.network(
'https://wallpaperplay.com/walls/full/e/5/3/13586.jpg',
fit: BoxFit.cover,
),
ColorFiltered(
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.8), BlendMode.srcOut), // This one will create the magic
child: Stack(
fit: StackFit.expand,
children: [
Container(
decoration: BoxDecoration(
color: Colors.black,
backgroundBlendMode: BlendMode.dstOut), // This one will handle background + difference out
),
Align(
alignment: Alignment.topCenter,
child: Container(
margin: const EdgeInsets.only(top: 80),
height: 200,
width: 200,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(100),
),
),
),
Center(
child: Text(
'Hello World',
style: TextStyle(fontSize: 70, fontWeight: FontWeight.w600),
),
)
],
),
),
],
),
);
}
This one you not only create "holes" over views, it works with anything! including texts, etc.
Final result:

Flutter Container with Network Image and an Aligned Container at the bottom

So, I have to display an image in a container and some description at the bottom of the container. The image is supposed to fill the entire screen. The image is being fetched from the network.
This is my intial approach
Stack(
fit: StackFit.expand,
children: <Widget>[
Container(
child: ClipRRect(
child: Image.network(category.imageURL,
height: maxHeight * 1, fit: BoxFit.cover),
),
),
Align(
alignment: Alignment.bottomLeft,
child: getNameAndDeleteSection(context),
)
],
),
),
where getNameAndDeleteSection is basically this
return Container(
color: Colors.yellow,
margin: EdgeInsets.fromLTRB(5, 0, 5, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
category.name,
maxLines: 1,
style: TextStyle(color: Colors.white),
),
Spacer(),
IconButton(
icon: Icon(Icons.delete, size: 18.0, color: Colors.white,),
onPressed: () {
deleteTap(category);
},
)
],
),
);
}
When the network image is loaded, it hides the yellow container , but keeps the children. What I want is the image to remain at the background and the yellow container to remain above it. The idea is that the yellow container will have a transparent color of sorts , to make it look floating on the image.
The max height is the height provided by the listView. I'm trying to make the UI adaptive. Any help?
Why not puting your image as a BoxDecoration in your container like this:
Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(url), fit: BoxFit.cover,
),
),
),
Align(
alignment: Alignment.bottomLeft,
child: getNameAndDeleteSection(context),
)
],
),
Instead of using a Container that always seems to get hidden by the Network Image, I decided to use Card that will envelop the container. And it worked.
So, the change was done in the getNameAndDeleteSection and basically wrapped the entire code in a Card. And bingo, it worked.