getx_route_generator 1.0.2 copy "getx_route_generator: ^1.0.2" to clipboard
getx_route_generator: ^1.0.2 copied to clipboard

getx_route_generator is a code generation library based on build_runner, designed to generate a route table for pages using the GetX library. Say goodbye to manually writing route paths and GetPage mappings.

getx_route_generator #

Language: English | 中文

getx_route_generator is a code generation library based on build_runner, designed to generate a route table for pages using the GetX library. Say goodbye to manually writing route paths and GetPage mappings.

Usage #

Add the latest version of getx_route_generator to your dependencies.

  dependencies: 
    getx_route_annotations: [latest-version]

  dev_dependencies:                    
    getx_route_generator: [latest-version]  

Add the GetXRoutePage annotation above the class of the specific route page.

@GetXRoutePage("/home")
class HomePage extends StatefulWidget {}

(PS: GetXRoutePage requires passing a path. In the generated route table class, a global variable like the one below will be automatically generated and can be used directly.)

static const String home = '/home';

Then run the following command in the terminal:

flutter pub run build_runner build

getx_route_generator will automatically generate a route_table.dart file in the lib/generated directory based on the annotations you added. The generated code looks like this:

import 'package:get/get.dart';
import 'package:xxx/page/home_page.dart';

class RouteTable {
  static const String home = '/home';

  static final List<GetPage> pages = [
    GetPage(name: '/home', page: () => HomePage()),
  ];
}

It's that simple!

2
likes
0
points
60
downloads

Publisher

unverified uploader

Weekly Downloads

getx_route_generator is a code generation library based on build_runner, designed to generate a route table for pages using the GetX library. Say goodbye to manually writing route paths and GetPage mappings.

Repository (GitHub)
View/report issues

Topics

#getxroutegenerator #getx #getpage #route #buildrunner

License

unknown (license)

Dependencies

build, build_runner, getx_route_annotations, glob, source_gen

More

Packages that depend on getx_route_generator