fluro icon indicating copy to clipboard operation
fluro copied to clipboard

Example is over-engineerd

Open lil5 opened this issue 3 years ago • 2 comments

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;
  }
}

lil5 avatar Sep 16 '21 10:09 lil5

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

ignertic avatar Sep 28 '21 10:09 ignertic

@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.

lil5 avatar Dec 04 '21 23:12 lil5