简体   繁体   English

焦点焦点节点上的颤动余量

[英]Flutter margin onFocus FocusNode

How do I set the margin from the edge when the focus hits a specific FocusNode ?当焦点击中特定的FocusNode时,如何设置边缘的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?从视频中可以看到,按钮顶部有一个缩进,但是当您滚动屏幕并将焦点返回到按钮时,它会粘在屏幕顶部,可以理解,按钮在屏幕上和焦点,但如何从顶部做一个小的偏移?

例子

Try something like this:尝试这样的事情:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM