feat: navigasi with param

This commit is contained in:
akhdanre 2025-04-27 22:26:53 +07:00
parent effaa4cdd7
commit 6adcb2e471
3 changed files with 17 additions and 2 deletions

View File

@ -3,6 +3,15 @@ import 'package:get/get.dart';
class NavigationController extends GetxController {
RxInt selectedIndex = 0.obs;
@override
void onInit() {
super.onInit();
final args = Get.arguments;
if (args != null && args is int) {
selectedIndex.value = args;
}
}
void changePage(int page) {
selectedIndex.value = page;
}

View File

@ -64,7 +64,7 @@ class QuizPreviewController extends GetxController {
if (success) {
Get.snackbar('Sukses', 'Kuis berhasil disimpan!');
Get.offAllNamed(AppRoutes.mainPage);
Get.offAllNamed(AppRoutes.mainPage, arguments: 2);
}
} catch (e) {
logC.e(e);

View File

@ -1,13 +1,19 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:quiz_app/app/app.dart';
import 'package:quiz_app/core/utils/logger.dart';
void main() {
runZonedGuarded(() {
runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(MyApp());
}, (e, stackTrace) {
logC.e("issue message $e || $stackTrace");