diff --git a/stream_chat_v1/lib/main.dart b/stream_chat_v1/lib/main.dart index 5c7dfa3..63169e7 100644 --- a/stream_chat_v1/lib/main.dart +++ b/stream_chat_v1/lib/main.dart @@ -40,6 +40,7 @@ class _MyAppState extends State with TickerProviderStateMixin { Animation _animation; AnimationController _animationController; Animation _colorAnimation; + int timeOfStartMs; Future _initConnection() async { final secureStorage = FlutterSecureStorage(); @@ -67,6 +68,7 @@ class _MyAppState extends State with TickerProviderStateMixin { @override void initState() { + timeOfStartMs = DateTime.now().millisecondsSinceEpoch; _animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 300)); _animation = Tween(begin: 0.0, end: 1000.0).animate( @@ -97,7 +99,17 @@ class _MyAppState extends State with TickerProviderStateMixin { : Colors.black) .animate(CurvedAnimation( parent: _animationController, curve: Curves.easeInOut)); - _animationController.forward(); + + var now = DateTime.now().millisecondsSinceEpoch; + + if (now - timeOfStartMs > 1000) { + _animationController.forward(); + } else { + var diff = 1000 - (now - timeOfStartMs); + Future.delayed(Duration(milliseconds: diff)).then((value) { + _animationController.forward(); + }); + } }, ); _animationController.addStatusListener((status) {