小编Tho*_*mas的帖子

使用Flutter,如何在iOS上触发TextField的onSubmitted()?

请查看下面的Flutter代码片段:它创建一个TextField用作单行输入字段,当按下Return时,它将提交其值:

child: new TextField(
  decoration: _deco,
  maxLines: 1,
  autofocus: true,
  onSubmitted: (newValue) {print(newValue);},
  onChanged: (newValue) {
    setState(() {
      strTemperature = newValue.trim();
    });
  })),
Run Code Online (Sandbox Code Playgroud)

在iOS模拟器上,相应的应用程序如下所示:

我的示例应用的屏幕截图

正如您所看到的那样配置了小部件maxLines = 1,但是当我单击屏幕键盘上的Return键时,会插入换行符.请在小部件下面的几行找到窄蓝色光标.此外,我看到没有控制台输出,因为我的onSubmitted()lambda 应该是这种情况.

我正确配置文本字段,还是我遗漏了什么?

dart flutter

9
推荐指数
1
解决办法
4984
查看次数

如何在iOS上的Gluon Mobile中使用PositionService?

我想PositionService在iOS上使用Gluon Mobile.我编写了一个在桌面上运行的小型示例应用程序,提供(按预期)假位置更改,以及在Android上.但是,在iOS模拟器上,不会调用侦听器.以下是代码的相关部分:

public class BasicView extends View {

        private static final Logger LOGGER = Logger.getLogger(BasicView.class.getName());

        final Label label;

        public BasicView(String name) {
            super(name);
            label = new Label();
            VBox controls = new VBox(15.0, label);
            controls.setAlignment(Pos.CENTER);
            setCenter(controls);
            // get current position
            Platform p = PlatformFactory.getPlatform();
            PositionService ps = p.getPositionService();
            outputPos(ps.getPosition());
            ps.positionProperty().addListener((obs, oldPos, newPos) -> {
                LOGGER.log(Level.INFO, "\nobs: {0}\noldPos: {1}\nnewPos: {2}",
                        new Object[]{obs, oldPos, newPos});
                outputPos(newPos);
            });
        }

        private void outputPos(Position p) {
            if (p != null) {
                label.setText(String.format("We are currently …
Run Code Online (Sandbox Code Playgroud)

gluon-mobile

8
推荐指数
1
解决办法
384
查看次数

标签 统计

dart ×1

flutter ×1

gluon-mobile ×1