-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanding.dart
54 lines (46 loc) · 1.45 KB
/
landing.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import 'package:flutter/material.dart';
import 'package:flutter_spotify_africa_assessment/features/landing/presentation/animations/rive_assets.dart';
import 'package:flutter_spotify_africa_assessment/routes.dart';
import 'package:rive/rive.dart';
class LandingPage extends StatefulWidget {
static const String _spotifyCategoryId = "afro";
const LandingPage({Key? key}) : super(key: key);
@override
State<LandingPage> createState() => _LandingPageState();
}
class _LandingPageState extends State<LandingPage> {
late RiveAnimationController _controller;
@override
void initState() {
super.initState();
_controller = OneShotAnimation(
RiveAssets.palotaIntroAnimationName,
onStop: () {
Future.delayed(const Duration(seconds: 1)).then(
(value) => _navigateToSpotifyCategoryPage(context),
);
},
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: RiveAnimation.asset(
RiveAssets.palotaIntro,
alignment: Alignment.center,
fit: BoxFit.contain,
controllers: [_controller],
),
);
}
void _navigateToSpotifyCategoryPage(BuildContext context) {
// replace because we don't want to navigate back to the landing screen
Navigator.of(context).pushReplacementNamed(AppRoutes.spotifyCategory,
arguments: LandingPage._spotifyCategoryId);
}
}