I have a class page route AppointmentCreatePage which required a parameter from a class model , but I define this import model as a prefix
AppointmentCreatePage class
import 'package:project_mobile/features/brand/model/brand_response_model.dart'
as model_brand;
class AppointmentCreatePage extends StatefulWidget {
const AppointmentCreatePage({Key? key, this.brandData}) : super(key: key);
final model_brand.Data? brandData; <--- use import as prefix
@override
State<AppointmentCreatePage> createState() => _AppointmentCreatePageState();
}
and the generated file (router.gr.dart)
/// generated route for
/// [AppointmentCreatePage]
class AppointmentCreateRoute extends PageRouteInfo<AppointmentCreateRouteArgs> {
AppointmentCreateRoute({
Key? key,
Data? brandData, <--- Error Undefined class 'Data'
}) : super(
AppointmentCreateRoute.name,
path: '/appointment-create-page',
args: AppointmentCreateRouteArgs(
key: key,
brandData: brandData,
),
);
static const String name = 'AppointmentCreateRoute';
}
class AppointmentCreateRouteArgs {
const AppointmentCreateRouteArgs({
this.key,
this.brandData,
});
final Key? key;
final Data? brandData; <--- Error Undefined class 'Data'
@override
String toString() {
return 'AppointmentCreateRouteArgs{key: $key, brandData: $brandData}';
}
}
what I expect is final Data? brandData;
on(router.gr.dart) can be generated same as like on the AppointmentCreatePage class final model_brand.Data? brandData
and on the router.dart can automatically import this class model
router.dart
import 'package:project_mobile/features/brand/model/brand_response_model.dart'
as model_brand; <--- expect can be imported automatically
part 'router.gr.dart';
@MaterialAutoRouter(
replaceInRouteName: 'Page,Route',
preferRelativeImports: true,
routes: <AutoRoute>[
AutoRoute(
page: SplashPage,
initial: true,
),
AutoRoute(page: OnBoardingPage),
AutoRoute(page: TabShowCasePage),
AutoRoute(page: LoginPage),
AutoRoute(page: ForgotPasswordPage),
AutoRoute(page: VerificationPage),
AutoRoute(page: RegisterPage),
AutoRoute(page: AppointmentCreatePage),
],
)
class AppRouter extends _$AppRouter{}