0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CupertinoPicker(選択系のUI)を高速で動かすと値がおかしくなる

Last updated at Posted at 2021-02-10

CupertinoPickerとは?

https://api.flutter.dev/flutter/cupertino/CupertinoPicker-class.html
スクリーンショット 2021-02-10 20.15.06.png
IOSのよく見るセレクター

発生した問題

CupertinoPickerを高速で動かすとおそらくsetstateの処理の後に非同期処理が完了して値の変更が起こっため選択した物が表示されないで一つ前の要素が表示される

原因

setState内で非同期処理を呼んでいた。

    setState(() {
      Future(() async {
       //非同期処理
      });
    });

解決法

CupertinoPickerなど高速に選択が変わるUIに対しては値を設定する際は非同期処理は行わないようにする。DropDownMenuなどは非同期処理で値を変更しても問題なさそう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?