Flutter hold splash screen for 3 Seconds. How to implement splash screen in Flutter?

前端 未结 9 2007
后悔当初
后悔当初 2021-02-16 00:16

How to show splash screen in flutter for 3 seconds and then go next my login screen.

I have tried.countdowntimer but import is unresolved

import \'pack         


        
9条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-16 00:34

    I needed a widget with 5 seconds delay. My solution was as following:

    class Waiting extends StatefulWidget {
      @override
      _WaitingState createState() => _WaitingState();
    }
    
    class _WaitingState extends State {
      bool voxt = false;
    
      @override
      Widget build(BuildContext context) {
        return FutureBuilder(
          future: Future.delayed(Duration(seconds: 3)),
          builder: (c, s) => s.connectionState != ConnectionState.done
              ? Text('Waiting')
              : Text('3 sec passed')
        );
      }
    }
    

    Now Waiting widget can be called where needed.

提交回复
热议问题