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

Example is over-engineerd #251

Open
lil5 opened this issue Sep 16, 2021 · 2 comments
Open

Example is over-engineerd #251

lil5 opened this issue Sep 16, 2021 · 2 comments

Comments

@lil5
Copy link

lil5 commented Sep 16, 2021

To read and understand how fluro work I have needed to read 5+ files.
Meanwhile having implemented fluro into my project only using 2 files for route initialization.

Might I suggest something like this?

// /main.dart
import 'package:flutter/material.dart';
import 'app/router.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyApp createState() => _MyApp();
}

class _MyApp extends State<MyApp> {
  final router = Routes.getRouter();

  // render
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      initialRoute: '/',
      onGenerateRoute: router.generator,
    );
  }
}
// /app/router.dart
import 'package:fluro/fluro.dart';

class Routes {
  static FluroRouter getRouter() {
    final router = FluroRouter();

    router.define(
      "/",
      handler: Handler(handlerFunc: (context, params) => const HomePage()),
    );
    router.define(
      "/chat",
      handler: Handler(handlerFunc: (context, params) => const SecondPage()),
      transitionType: TransitionType.fadeIn,
    );

    return router;
  }
}
@ignertic
Copy link

I'm actually gonna use this to try out the package

@lil5
Copy link
Author

lil5 commented Dec 4, 2021

@lukepighetti Would you be interested in receiving a Pull Request replacing or adding this example?

If so I will try to make the time to create one.

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