Home > front end >  Flutter margin onFocus FocusNode
Flutter margin onFocus FocusNode

Time:10-29

How do I set the margin from the edge when the focus hits a specific FocusNode?

As you can see from the video, there is an indentation on top of the buttons, but when you scroll the screen and return the focus to the button, it sticks to the top of the screen, it's understandable, the button is on the screen and in focus, but how to make a small offset from the top?

Example

CodePudding user response:

Try something like this:

Container(
 margin: EdgeInsets.only(top:  (focusnode.hasFocus) ? 10 : 0),
 child: Text((focusnode.hasFocus) ? 'In Focus' : 'No Focus');
);
  • Related