How to run code after some delay in Flutter?

前端 未结 10 1595
無奈伤痛
無奈伤痛 2020-12-23 00:24

I\'d like to execute a function after a certain delay after my Widget is built. What\'s the idiomatic way of doing this in Flutter?

What I\'m trying to achieve: I\'

10条回答
  •  心在旅途
    2020-12-23 00:41

    Just leaving here the snippet everyone is looking for:

    Future.delayed(Duration(milliseconds: 100), () {
      // Do something
    });
    

提交回复
热议问题