[bug]: Migrating to Navigator 2.0 is not updating existing app.route.dart file
Closed this issue · 4 comments
Describe the bug
I was following this guide to migrate to Navigator 2.0: https://stacked.filledstacks.com/docs/stacked-router/routing-basics
But after running 'stacked generate' multiple times, my app.route.dart still remains the same as it was previously (NOT using StackedRouterWeb).
What operating system do you use?
macOS
Information about the installed tooling
-- dev dependancies
build_runner: ^2.4.5
stacked_generator: ^1.3.3
-- dependancies
stacked: ^3.4.0
stacked_services: ^1.1.0
Steps to reproduce the issue
--app.dart file
import 'package:flutter_ui/services/authentication_service.dart';
import 'package:flutter_ui/services/local_notification_service.dart';
import 'package:flutter_ui/services/push_notification_service.dart';
import 'package:flutter_ui/services/settings_service.dart';
import 'package:flutter_ui/ui/bottom_sheets/alert/alert_sheet.dart';
import 'package:flutter_ui/ui/bottom_sheets/notice/notice_sheet.dart';
import 'package:flutter_ui/ui/dialogs/info_alert/info_alert_dialog.dart';
import 'package:flutter_ui/ui/views/first_screen/first_screen_view.dart';
import 'package:flutter_ui/ui/views/home/home_view.dart';
import 'package:flutter_ui/ui/views/second_screen/second_screen_view.dart';
import 'package:flutter_ui/ui/views/settings/settings_view.dart';
import 'package:flutter_ui/ui/views/signup/signup_view.dart';
import 'package:flutter_ui/ui/views/startup/startup_view.dart';
import 'package:flutter_ui/ui/views/third_screen/third_screen_view.dart';
import 'package:stacked/stacked_annotations.dart';
import 'package:stacked_services/stacked_services.dart';
import 'package:flutter_ui/services/google_cloud_logging_service.dart';
// @stacked-import
@StackedApp(
logger: StackedLogger(),
routes: [
MaterialRoute(page: StartupView, initial: true),
MaterialRoute(page: HomeView),
MaterialRoute(page: SettingsView),
MaterialRoute(page: SignupView),
MaterialRoute(page: SecondScreenView),
MaterialRoute(page: ThirdScreenView),
MaterialRoute(page: FirstScreenView),
// @stacked-route
],
dependencies: [
LazySingleton(classType: BottomSheetService),
LazySingleton(classType: DialogService),
LazySingleton(classType: RouterService),
LazySingleton(classType: SettingsService),
LazySingleton(classType: AuthenticationService),
LazySingleton(classType: PushNotificationService),
LazySingleton(classType: LocalNotificationService),
LazySingleton(classType: GoogleCloudLoggingService),
// @stacked-service
],
bottomsheets: [
StackedBottomsheet(classType: NoticeSheet),
StackedBottomsheet(classType: AlertSheet),
// @stacked-bottom-sheet
],
dialogs: [
StackedDialog(classType: InfoAlertDialog),
// @stacked-dialog
],
)
class App {}
// app.router.dart
import 'package:flutter/foundation.dart' as _i10;
import 'package:flutter/material.dart' as _i9;
import 'package:flutter/material.dart';
import 'package:flutter_ui/ui/views/first_screen/first_screen_view.dart' as _i8;
import 'package:flutter_ui/ui/views/home/home_view.dart' as _i3;
import 'package:flutter_ui/ui/views/second_screen/second_screen_view.dart'
as _i6;
import 'package:flutter_ui/ui/views/settings/settings_view.dart' as _i4;
import 'package:flutter_ui/ui/views/signup/signup_view.dart' as _i5;
import 'package:flutter_ui/ui/views/startup/startup_view.dart' as _i2;
import 'package:flutter_ui/ui/views/third_screen/third_screen_view.dart' as _i7;
import 'package:stacked/stacked.dart' as _i1;
import 'package:stacked_services/stacked_services.dart' as _i11;
class Routes {
static const startupView = '/';
static const homeView = '/home-view';
static const settingsView = '/settings-view';
static const signupView = '/signup-view';
static const secondScreenView = '/second-screen-view';
static const thirdScreenView = '/third-screen-view';
static const firstScreenView = '/first-screen-view';
static const all = <String>{
startupView,
homeView,
settingsView,
signupView,
secondScreenView,
thirdScreenView,
firstScreenView,
};
}
class StackedRouter extends _i1.RouterBase {
final _routes = <_i1.RouteDef>[
_i1.RouteDef(
Routes.startupView,
page: _i2.StartupView,
),
_i1.RouteDef(
Routes.homeView,
page: _i3.HomeView,
),
_i1.RouteDef(
Routes.settingsView,
page: _i4.SettingsView,
),
_i1.RouteDef(
Routes.signupView,
page: _i5.SignupView)
Expected behavior
No response
Screenshots
No response
Additional Context
No response
Please post the navigator2 section from your build.yml
as well.
I used the one from documentation:
targets:
$default:
builders:
stacked_generator|stackedRouterGenerator:
options:
navigator2: true
Interesting, it's working for me as expected.
Can you maybe upload the code and link it here for me to download? I'd like to try locally and see what's causing it.
My bad. I used build.yml instead of build.yaml. Closing this one. Thanks anyway!!