I'm trying to use the Get package as a sort of Navigator but when I want to go to another page, the app returns me a black page, with a big X on it.
Here the code of the main:
Widget build(BuildContext context) {
return GetMaterialApp(
theme: MyAppTheme.lightTheme,
darkTheme: MyAppTheme.darkTheme,
themeMode: ThemeMode.system,
home: SplashScreen(),
);
}
My SplashScreen: (note the startAnimation() method at the beginning, right before the Scaffold)
class SplashScreen extends StatelessWidget {
SplashScreen({super.key});
final splashScreenController = Get.put(SplashScreenController());
@override
Widget build(BuildContext context) {
splashScreenController.startAnimation();
return Scaffold(
body: Obx(
() => AnimatedOpacity(
duration: Duration(milliseconds: 1000),
opacity: splashScreenController.animate.value ? 1 : 0,
child: Stack(
children: [
Obx(
() => AnimatedPositioned(
duration: Duration(milliseconds: 2000),
top: splashScreenController.animate.value ? -20 : -30,
left: splashScreenController.animate.value ? -20 : -50,
width: 170,
height: 170,
child: Image(
image: AssetImage(iconaCerchioBlu),
),
),
),
Obx(
() => AnimatedPositioned(
duration: Duration(milliseconds: 2000),
top: splashScreenController.animate.value ? 190 : 160,
left: splashScreenController.animate.value ? 100 : 120,
width: 300,
height: 300,
child: const Image(
image: AssetImage(iconaCerchioVerde),
),
),
),
AnimatedPositioned(
duration: Duration(milliseconds: 500),
top: 520,
left: 0,
height: 170,
width: 390,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
myAppName,
style: Theme.of(context).textTheme.displayLarge,
),
Text(
myAppTagLine,
style: Theme.of(context).textTheme.displayMedium,
),
],
),
)
),
Obx(
() => AnimatedPositioned(
duration: Duration(milliseconds: 2000),
top: splashScreenController.animate.value ? 700 : 750,
left: splashScreenController.animate.value ? 0 : 30,
child: Image(
image: AssetImage(iconaCerchioBlu),
),
),
)
],
),
),
),
);
}
}
My SplashScreenController: (It should move the focus on the page to next Widget after 5 seconds, but it doesn't work)
class SplashScreenController extends GetxController {
static SplashScreenController get find => Get.find();
RxBool animate = false.obs;
Future startAnimation() async {
await Future.delayed(Duration(milliseconds: 500)); //0.5s
animate.value = true;
await Future.delayed(Duration(milliseconds: 5000));
Get.to(() => WelcomeScreen());
}
}
And the Welcome() page:
Widget build(BuildContext context) {
return Placeholder(
child: Text(
"Ciao, sono la schermata Home",
style: Theme.of(context).textTheme.displayMedium,
),
);
}
I've already tried to use Get.to( () => WelcomeScreen() ) instead of what I've put in the code above.
Have you got and idea of the reason of that? Thanks!