Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.59k stars 405 forks source link

[dynamic] is not a class #103

Closed YasserOJ closed 3 years ago

YasserOJ commented 4 years ago

Hello, when I am trying to generate the routes for my app using flutter pub run build_runner build

I'm getting an error and the generated class can't be generated I only see [dynamic] is not a class in the generated class

sennraf commented 4 years ago

Did you try to clean and rebuild it? That worked for me. flutter packages pub run build_runner clean and then flutter packages pub run build_runner build

YasserOJ commented 4 years ago

Hello, yes I tried it and it still the same

Milad-Akarie commented 4 years ago

Hey @YasserOJ Can you show me your router setup?

HosseinYousefi commented 4 years ago

I have the same issue. It doesn't work with functional_widget package.

rafaelmpessoa commented 4 years ago
[SEVERE] auto_route_generator:autoRouteGenerator on lib/presentation/router.dart:
 Error running AutoRouteGenerator
 [dynamic] is not a class

I have the same problem and I don't know what cause of it. I guess that some cache. It's difficult to reproduce locally, but in my gitlab-ci always happens.

I tried to run flutter packages pub run build_runner clean and didn't work for me.

This problem started when I change the relative path of my page widgets. Example, I change import 'package:pix/presentation/page/transfer/transfer_feedback/transfer_feedback_page.dart'; to import 'package:pix/presentation/transfer/transfer_feedback/transfer_feedback_page.dart';

Steps when I reproduce it locally: delete router.g.dart than run flutter clean , flutter pub get then flutter pub run build_runner build --delete-conflicting-outputs, if i run flutter pub run build_runner build --delete-conflicting-outputs no error anymore.

my `router.dart``

import 'package:auto_route/auto_route_annotations.dart';
import 'package:pix/presentation//home/home_page.dart';
import 'package:pix/presentation/receive/receive_message/receive_message_page.dart';
import 'package:pix/presentation/receive/receive_page.dart';
import 'package:pix/presentation/receive/receive_qrcode/receive_qrcode_page.dart';
import 'package:pix/presentation/receive/receive_value/receive_value_page.dart';
import 'package:pix/presentation/transfer/transfer_page.dart';
import 'package:pix/presentation/transfer/transfer_feedback/transfer_feedback_page.dart';
import 'package:pix/presentation/transfer/transfer_manual/description/transfer_manual_description_page.dart';
import 'package:pix/presentation/transfer/transfer_manual/account/transfer_manual_account_page.dart';
import 'package:pix/presentation/transfer/transfer_manual/agency/transfer_manual_agency_page.dart';
import 'package:pix/presentation/transfer/transfer_manual/bank_select/transfer_manual_bank_select_page.dart';
import 'package:pix/presentation/transfer/transfer_manual/ownership/transfer_manual_ownership_page.dart';
import 'package:pix/presentation/transfer/transfer_resume/transfer_resume_page.dart';
import 'package:pix/presentation/transfer/transfer_value/transfer_value_page.dart';

@MaterialAutoRouter()
class $Router {
  @initial
  HomePage homePage;
  TransferPage transferPage;
  TransferValuePage transferValuePage;
  TransferResumePage transferResumePage;
  TransferFeedbackPage transferFeedbackPage;
  TransferManualBankSelectPage transferManualBankSelectPage;
  TransferManualOwnershipPage transferManualOwnershipPage;
  TransferManualDescriptionPage transferManualDescriptionPage;
  TransferManualAgencyPage transferManualAgencyPage;
  TransferManualAccountPage transferManualAccountPage;
  ReceivePage receivePage;
  ReceiveMessagePage receiveMessagePage;
  ReceiveValuePage receiveValuePage;
  ReceiveQrcodePage receiveQrcodePage;
}
rafaelmpessoa commented 4 years ago

I got it locally. @Milad-Akarie

for my case, steps: flutter clean flutter pub get flutter pub run build_runner clean flutter pub run build_runner build --delete-conflicting-outputs

rafaelmpessoa commented 4 years ago

I don't know why but I change the absolute path to relative path and works.

import 'home/home_page.dart';
import 'receive/receive_message/receive_message_page.dart';
import 'receive/receive_page.dart';
import 'receive/receive_qrcode/receive_qrcode_page.dart';
import 'receive/receive_value/receive_value_page.dart';
import 'transfer/transfer_feedback/transfer_feedback_page.dart';
import 'transfer/transfer_manual/account/transfer_manual_account_page.dart';
import 'transfer/transfer_manual/agency/transfer_manual_agency_page.dart';
import 'transfer/transfer_manual/bank_select/transfer_manual_bank_select_page.dart';
import 'transfer/transfer_manual/description/transfer_manual_description_page.dart';
import 'transfer/transfer_manual/ownership/transfer_manual_ownership_page.dart';
import 'transfer/transfer_page.dart';
import 'transfer/transfer_resume/transfer_resume_page.dart';
import 'transfer/transfer_value/transfer_value_page.dart';
theweiweiway commented 3 years ago

Closing issue due to: