Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error - compilation never finalises. #17

Closed
fringefilmsoz opened this issue Jan 17, 2020 · 4 comments
Closed

Error - compilation never finalises. #17

fringefilmsoz opened this issue Jan 17, 2020 · 4 comments

Comments

@fringefilmsoz
Copy link

Hi Milad, first of all thanks for an awesome Plugin.

I'm having an issue with my generated routes causing some sort of flutter error. My flutter program is never fully compiled (i.e Android Studio doesn't show the hot reload button). The UI actually works and you can navigate around.

Occurring for Android API 28 and 29.

I have no idea if this is an issue with the emulator, Flutter, Android Studio or the plugin generated code.

I generated my code based on Reso's tutorial:
https://resocoder.com/2020/01/10/flutter-zero-boilerplate-router-with-auto-route-flutter-navigation-tutorial/

But i get stuck with the following message:

D/FlutterView( 6866): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@e184f11
D/FlutterActivityAndFragmentDelegate( 6866): Executing Dart entrypoint: main, and sending initial route: /
This is taking longer than expected...

Code:
Main.dart

import 'package:fhir_test/bloc/bloc.dart';
import 'package:fhir_test/route/router.gr.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(
      providers: [
        BlocProvider<PatientBloc>(
          create: (BuildContext context) => PatientBloc(),
        ),
      ],
      child: MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        initialRoute: Router.homePage,
        onGenerateRoute: Router.onGenerateRoute,
        navigatorKey: Router.navigatorKey,
      ),
    );
  }
}

Router

import 'package:auto_route/auto_route_annotations.dart';
import 'package:fhir_test/ui/homePage.dart';
import 'package:fhir_test/ui/patientSearchPage.dart';

@autoRouter
class $Router {
  @initial
  HomePage homePage;
  PatientSearchPage patientSearchPage;
}

Routes

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:auto_route/router_utils.dart';
import 'package:fhir_test/ui/homePage.dart';
import 'package:fhir_test/ui/patientSearchPage.dart';

class Router {
  static const homePage = '/';
  static const patientSearchPage = '/patientSearchPage';
  static GlobalKey<NavigatorState> get navigatorKey =>
      getNavigatorKey<Router>();
  static NavigatorState get navigator => navigatorKey.currentState;

  static Route<dynamic> onGenerateRoute(RouteSettings settings) {
    final args = settings.arguments;
    switch (settings.name) {
      case Router.homePage:
        return MaterialPageRoute(
          builder: (_) => HomePage(),
          settings: settings,
        );
      case Router.patientSearchPage:
        if (hasInvalidArgs<PatientSearchPageArguments>(args)) {
          return misTypedArgsRoute<PatientSearchPageArguments>(args);
        }
        final typedArgs =
            args as PatientSearchPageArguments ?? PatientSearchPageArguments();
        return MaterialPageRoute(
          builder: (_) =>
              PatientSearchPage(key: typedArgs.key, title: typedArgs.title),
          settings: settings,
        );
      default:
        return unknownRoutePage(settings.name);
    }
  }
}

//**************************************************************************
// Arguments holder classes
//***************************************************************************

//PatientSearchPage arguments holder class
class PatientSearchPageArguments {
  final Key key;
  final String title;
  PatientSearchPageArguments({this.key, this.title});
}

Flutter Doctor:

[√] Flutter (Channel dev, v1.14.1, on Microsoft Windows [Version 10.0.17134.1130], locale en-AU)
• Flutter version 1.14.1 at C:\flutter
• Framework revision c88320458e (32 hours ago), 2020-01-15 11:38:02 -0500
• Engine revision bc41ab5139
• Dart version 2.8.0 (build 2.8.0-dev.1.0 fe666ce592)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:/Users/pullend/AppData/Local/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = C:/Users/pullend/AppData/Local/Android/Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.41.1)
• VS Code at C:\Users\pullend\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.7.1

[!] Proxy Configuration
• HTTP_PROXY is set
! NO_PROXY is not set

[√] Connected device (3 available)
• AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• Chrome • chrome • web-javascript • Google Chrome 79.0.3945.117
• Web Server • web-server • web-javascript • Flutter Tools

! Doctor found issues in 1 category.

@fringefilmsoz fringefilmsoz changed the title Error - comilation never finalises. Error - compilation never finalises. Jan 17, 2020
@fringefilmsoz
Copy link
Author

fringefilmsoz commented Jan 17, 2020

Additional info: In VS Code, the same error occurs, but the UI is not displayed at all.

Stuck in 'Running Gradle task Assemble Debug'.

@fringefilmsoz
Copy link
Author

fringefilmsoz commented Jan 17, 2020

Ok, so i found the docs on Wrappers, but I was unable to get it working.

Here's what I tried... but still the same results:

Main.dart

import 'package:auto_route/auto_route_wrapper.dart';
import 'package:fhir_test/bloc/bloc.dart';
import 'package:fhir_test/route/router.gr.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget implements AutoRouteWrapper {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(
      providers: [
        BlocProvider<PatientBloc>(
          create: (BuildContext context) => PatientBloc(),
        ),
      ],
      child: MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        initialRoute: Router.homePage,
        onGenerateRoute: Router.onGenerateRoute,
        navigatorKey: Router.navigatorKey,
      ),
    );
  }

  @override

  Widget get wrappedRoute => MultiBlocProvider(providers: [
        BlocProvider<PatientBloc>(
          create: (BuildContext context) => PatientBloc(),
        ),
      ], child: this);
}

@Milad-Akarie
Copy link
Owner

Milad-Akarie commented Jan 18, 2020

Hey @fringefilmsoz , I don't think your generated router has anything to do with your issue.
auto_route's task is to generate your router class for you before run time it instead of you manually writing it.

I'd suggest you do a flutter clean up first.
if that doesn't work remove auto route from your pub and try a build see if it's causing it to behave they way it does.

also can you show me your home page?

@fringefilmsoz
Copy link
Author

Hi,
It appears that Flutter developed some sort of issue. Even a new project wouldn't compile. Complete restart and Flutter Clean got me back on track... after a couple of hours of troubleshooting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants