How to put icon center of another icon in flutter - flutter

How to Put one icon in center of another icon like google map marker like below?

You should use "Stack" control in which you have to add the first icon with "Pin" and same add another with "Carry"
Widget getStack() {
return Stack(
children: <Widget>[
Center(
child: Icon(Icons.account_balance),
),
Center(
child: Icon(Icons.account_balance),
)
],
);
}

Related

Google Map is clickable under the SpeedDial overlay in flutter web

I developed a flutter web application that has google map widget as a part of Scaffold body. I use flutter_speed_dial as a floating action button. When I click on SpeedDial, it shows an overlay on whole screen, but the map is still clickable.
I know it is happened because google map use HtmlElementView in web and we have a pointer_interceptor package to prevent triggering map when click on above buttons. But how about the overlays? there is no place to wrap SpeedDial overlay with pointer_interceptor.
Here is my sample code:
Scaffold(
...
body: Column(
children: [
...
SizedBox(
height: 230,
child: GoogleMap(...)),
...
]
),
floatingActionButton: PointerInterceptor(
child: SpeedDial(
...
childPadding: const EdgeInsets.all(5),
spaceBetweenChildren: 1,
isOpenOnStart: false,
children: [
SpeedDialChild(
onTap: () {
...
},
labelWidget: PointerInterceptor(
child: Card(
...
),
),
),
],
),
),
)
I believe you can Solve your problem by using IgnorePointer.
Wrap a widget with IgnorePointer and set it to true.
IgnorePointer(
ignoring: true,
child: Widget _test(),
),
you can take a look at docs here:
https://api.flutter.dev/flutter/widgets/IgnorePointer-class.html

How to add button in Flutter

I am new in flutter.
I am following some YouTube videos to learn flutter. After adding a picture in card(home screen) now I want to add two buttons below that picture. how can i do it.
the picture Adding code
body: Center(
child: Card(
child: Column(
children: [Image.asset("assets/image-name")],
),
),
),
Here you have a great page, where you can find implementations of basic material widgets in Flutter.
For your example, it would look like this:
body: Center(
child: Card(
child: Column(
children: [
Image.asset("assets/image-name"),
ElevatedButton(
onPressed: () {
// Respond to button press
},
child: Text('CONTAINED BUTTON'),
)
],
),
),
),
For a second button, you can just add another one in the children array.
You can also wrap both buttons in Row widget, that will allow you to place them horizontally, next to each other.

Is there anything like PostfixIcon for TextField in flutter

I've already tried PrefixIcon for TextField in flutter but this time I'm looking for something like Postfix Clickable Icon in flutter. I'm attaching the image and I want to achieve something like that.
Where the Icon is clickable and on clicking the Icon it will display the other TextField.
Here's the Image:
Use a suffixIcon. If that doesn't behave how you'd expect, you can always use a Stack.
You can use a Stack Widget to do that. it works similar to a Row or a Column but its Stacks its children on top of each other.
https://api.flutter.dev/flutter/widgets/Stack-class.html
what you are trying to do this something like this,
Stack(
alignment: Alignment.centerRight,
children: <Widget>[
TextField(),
IconButton(icon: Icon(Icons.add), onPressed: (){
//Code
})
],
),
You can use a Stack Widget #Srilal Sachintha
Stack(
alignment: Alignment.centerRight,
children: <Widget>[
TextFormField(),
IconButton(icon: Icon(Icons.add), onPressed: (){
//Code
})
],
),
or Use a suffixIcon. If that doesn't behave how you'd expect, you can always use a Stack. #

What widget to use to get a sign up button with google logo at the left

I saved the google logo a as .png because I want to keep its colors. I am aware there are some packages for predefined sign-in buttons like google or with the google Icon(but I can't keep the colors obviously in this case), but I would like to know if I can somehow make so the .png image acts like an Icon.
You can use whatever button widget you like or you can create your custom button...
According to your image you can use outline button or flat button... then in your child parameter add Row with image and text
OutlineButton(child: Row(children: Image.asset(your_image_location), Text('Sign in with Google')))
body: Stack(
children: <Widget>[
Center(
child: IconButton(
icon: Image.asset('path/the_image.png'),
iconSize: 50,
onPressed: () {},
)
Positioned(
child: Container(
child: Center(child: Text('Sign in With Google')),
)),
],
)

How do I place a widget in the center of the screen while ignoring column?

There is a widget (for example text). In the real example it comes after another widget in Column. How to put it in the center of the screen? As I understand it, the Column does not. How can this be done? Or are there other ways to specify the location of items?
Column takes all the available space of the parent and by default aligns the items to start
You can change fix this changes the MainAxisAlignment to center.
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("test"),
],
),
or changing parents height and move it to the center (be careful if you add many items it will cause overflow)
child: Center(
child: Container(
height: 25,
child: Column(
children: <Widget>[
Text("test"),
],
),
),
),
Using Stack widget you can do it:
var textEmpty = Text("Some Text");
Stack(children: <Widget>[
Column(children: <Widget>[
Container(
,margin: EdgeInsets.only(top: 100.0)
,child: Center(child: textEmpty, ),)],),
listView,
]);
Use Center Wigdet instead of Container. Hope this helps!
No worries where it comes from. It depends on the view where you have added it.
If you want to show in the center then just use Center widget
If you want to use Container widget then, you have to add the width and height both to double.infinite
If you want to use it in the same widget then you can use the Stack widget as well.
It totally depends on the requirement of the view and in which way you are tried to implement it.