Flutter TextFormFiled inside the Card with elevation - flutter

I have taken a TextFormField in a Card Widget.I am not able to show the error message outside the Card Widget.The error message is showing inside the Card Widget which is not looking good .I have attached the image of the View which I wanted to show.Please Help me out regarding this.
This is what I get

Since you've not provided the code I'm going to assume that the card and button have been placed in a Column widget. Also, if you press the button it checks if phone number is present or not, if not present it adds the error message to the card.
If my assumptions are correct, you can use the following instead for the Error message,
Visibility (
visible: errmsgvisibility,
child: Text('Please enter phone number.'),
),
Where, 'errmsgvisibility' is a bool value which can be simply changed to true to display the message and made to false to hide the message. Make sure you initialize it to false.
Place the code in the Column widget between the Card and the sign in button.

Related

Flutter: How to display repeated value in the Text widget

I am a new in Flutter.
I want to make possible to show the same value when tapped on the button in the widget Text();
For example:
Button with value - (0) zero.
Tapping button -> shows 0.
Again Tapping button -> shows 00.
Again Tapping button -> shows 000
I my case I made just to when button is tapped I show the value zero, when I tap again nothing happens in the UI but in the console I see that button tapped.
As you see in the screenshot
14 flutter: Tap Number 1. In this case I tapped 14 time on the button.
enter image description here
I guess the problem could be with Flutter Keys.
I use the setState. As I understand setState change the value if it is changed but in my case when I tap several times same button with the same value nothing happened because the value is not changed, so UI does not change too, am I right ?
I do not need ready solution, I just want to get the advices how to work with such cases in order to make myself.
I just want to get the advices how to work with such cases in order to make myself.

Show info text after clicking an Icon

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.

Icon Dependent on Boolean not Changing when Boolean Value Changes (Flutter)

I'm trying to make a Flutter screen that changes the icon (from unchecked to checked) when the ListTile is tapped. I've continued on from the first Flutter app tutorial, https://docs.flutter.dev/get-started/codelab which has something very similar that functions.
However, when I tap my ListTile the boolean changes values (as evidenced by my print() statement), but the icon stays the same, despite using setState(). I'm brand new to Flutter, could someone please point out what I'm doing wrong?
Edit: It looks like I needed to wrap after builder: in a StatefulBuilder... but now the question is how to address each check box individually, instead of all at once?

Screenshot Controller flutter - capture method returns a null Uint8List when record is added

On the home screen on my app :
I have a list view with a bunch of card widgets and a screenshot action associated with each card widget. When I click on the screenshot action it captures the screenshot of that widget as it’s supposed to.
I have a floating action button which when clicked takes me to an add screen where I add data and save it to the database. Once saved a snackbar message is displayed and screen is popped out. The list view now displays the new record as a card widget.
PROBLEM :
After adding the record, when I click the screenshot action no widget screenshot is captured and on debugging I noticed the “Uint8List? image” is null.
Now if I scroll the list view and perform the screenshot action again everything seems to work.
It sounds to me that this might be a widget tree rebuild issue, but I am not sure how to go about with it. I have other actions, edit and delete on the card widget and they work without any issue.
Package used: screenshot 1.2.3

Flutter SnackBar leaves an invisible padding in the Scaffold

I am showing a log in button in a page. Once the user has logged in, the SnackBar will display "Logged In with Google" for example. While the SnackBar is still showing, the body of the Scaffold is being build to a new page, the one accessible by logged in users. However, building the page while the Snackbar is still showing somehow leaves a padding in the Scaffold, in the area used by the SnackBar, so the underlying Scaffold body is still visible, yet you cannot interact with it. If there is a button at the bottom of that body, the button is not tapped because the invisible padding left behind by the (already closed) SnackBar blocks the content underneath.
What am I missing? Is there another way to produce the desired result?
I wrapped the Scaffold with a ScaffoldMessenger in every page and now seems to work. I will elaborate on the answer later on.