Show info text after clicking an Icon - flutter

I am trying to implement a feature in Flutter in which user will be able to display additional information after clicking on the specific icon or image. I would like to display a small annotation above selected icon. The example of what i would like to achive is in the screen below.
Is there any ready to use widget for this feature?

you can use Tooltip widget for this as bellow
Tooltip(
message: "This is the tool tip",
child: Icon(Icons.add),
),
when you long press on the icon the message will be shown like this.

You can do this by using Stack. Place the Button first where you want the Stack to be.
You can write the information you want to put on top of the button in Positioned() inside the Stack.
Set a variable, show information when this variable is True otherwise hide it.
You can also use GestureDedector if you want it to close when you touch anywhere.

Related

How to show a container / dialog next to an icon when the icon is tapped?

Hi I'm trying to create a screen that have bunch of container with a child of row that have a text and a Icon (the red one - can be seen on the image). So when I click the icon I want to show a dialog right next to the icon. I tried using aligned_dialog but the positioning is really hard to do, I want it to be instantly next to the icon just like the image.
Is there any package or widget that I can use to achieve this ?
You can check this package: https://pub.dev/packages/just_the_tooltip
It allow to specify a child of type Widget, so you can add what you want.

DropdownButton - don't show popup on tap

I want to show my own page on dropdown button tap, then item selected on page should be set as dropdown button value.
So basically, I need DropdownButton without any popup on tap. When I use onTap still default popup will be shown, how to prevent that?
why you don't use a button instead? or you can try to create an Inkwell put a container on its child and make it look like a button and write your code inside Inkwell OnTap(){}
1- Pass null to items parameter to disable the button.
2- You'll notice icon's color will be grey with disabled button, you can change it by setting color of the icon you send to icon parameter or send color directly to iconDisabledColor parameter.
3- You'll not use value parameter, instead you'll just use hint to show both your hint and your value. and update it using your state management after you pick new value from your own page.
4- Wrap your DropdownButton with GestureDetector or InkWell to show your own page when you tap on the button.
5- If you want to customize your DropdownButton shape, size and more. You can try my new package DropdownButton2. It's simple, easy, based on Flutter's core DropdownButton and have lots of features.

Using AlertDialog on a stack widget in flutter

I have a basic layout where I am using a stack widget to hold my other widgets.. I have a side toolbar, inside that I have a pen menu on click of which a popup should appear. When i am clicking the pen menu an alert dialog appears but not in the expected place, what i mean is...
I am expecting a dialog like the one in the below image. Do I need to use any plugin to create a dialog like this with a chevron mark?enter image description here
As you are using Alert dialog, it will by default be aligned in center of your screen. In order to achieve what you are trying to, I would suggest using a plugin like this.

How to create a custom back press button?

I am new to flutter and curious if we can create a custom back press button, not the one in appbar.
Just like a normal button that takes back to previous screen.
Here's how you so that:
Create a raw material button
Add the on press method to decide which screen it goes to.
In you main.dart, under the routes method, import the screen you want to push the current screen back to and then call it something.
Inside your onPress() method, you can call Navigator.pushNamed(context, routeName).
Now you can customise this raw material button as much as you want. Here are some of the main properties you can set:
textStyle
fillColor
elevation
padding
constraints
shape
child
Now give a name to this custom button you have created by extracting it into a widget.
Call the widget inside your code! If you want it to be aligned at the top left, which is usually where you find it:
Align(
alignment: Alignment.topLeft,
child: CustomButton()
),
Enjoy! PS: If you need any help, feel free to ask me and I will assist you to my best abilities!

Flutter overlay is moving

I'm asking how to disable Overlays to move when a Scaffold.of(context).showSnackBar is called like on my video below.
The same thing is happening when the keyboard appear. Sometime the blue floattingButton (+) don't come back to it's original position :-(
Thx in advance.
Problem animation
The FloatingActionButton going up when the Scaffold is displayed is something common to all default implementations.
Give a look to the "Bootom app bar" demo in the Gallery app. Press on the search button and you will see it coming up. Or just add a Scaffold to the app that is built with flutter create command.
This happens because of the way the FAB button is placed on the screen and the effect of displaying the Snackbar by the Scaffold.
The FAB button is displayed at the bottom of the content area of the Scaffold content. When the content area is shrinked to include the BottomAppBar, the FAB goes up with it. It has nothing to do with Overlay.
You have two options:
Either you create your own versiĆ³n of the FAB which is not
controlled by the Scaffold.
Or you hack the Scaffold so the size of the SnackBar is not taken
into account.
For this second option you can try the following:
Go to the file /lib/src/material/scaffold.dart in your flutter installation and look for the line with the code snackBarSize: snackBarSize, inside the _ScaffoldLayout class.
Replace it with snackBarSize: Size(0.0, 0.0),
You will see that the FAB stays in its place.