0

Beginner question:

I'm trying to display a message as soon as the page display, I can do it with a simple custom message, but I couldn't find any standard way to do it, all search I did leads me to Snackbar or Flushbar, the problem with this 2 is that u can only show it after the build is called, e.g. on onPress, which leads me to the actual question:

How do I get a call back for onMount event, e.g. something like jQuery ready method, that is triggered once the page is mounted (i.e. ready), so that I can call Snackbar for example?

0

1 Answer 1

3

Duplicate to Flutter: Run method on Widget build complete

answer:

  @override
  void initState() {
    super.initState();


    if (SchedulerBinding.instance.schedulerPhase ==
        SchedulerPhase.persistentCallbacks) {
      SchedulerBinding.instance.addPostFrameCallback((_) {
        showInFlushbar("Some text");
      });
    }
    ;
  }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.