get_typed_router 0.0.1 copy "get_typed_router: ^0.0.1" to clipboard
get_typed_router: ^0.0.1 copied to clipboard

Type-safe, annotation-based route generation for GetX. Annotate your pages with @AppRoute, run the CLI generator, and get a fully typed AppRouter with type-safe navigation and strongly-typed argument [...]

example/lib/main.dart

import 'package:example/home/home_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_typed_router/get_typed_router.dart';
import 'routes/app_router.g.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Get Typed Router Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      initialRoute: MyHomePageRoute.route,
      getPages: AppRouter.pages,
    );
  }
}

@AppRoute<String>(path: '/second')
class SecondPage extends StatelessWidget {
  const SecondPage({super.key});

  @override
  Widget build(BuildContext context) {
    final message = AppRouter.getArgs<String>();

    return Scaffold(
      appBar: AppBar(title: const Text('Second Page')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('Received message: $message'),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () => AppRouter.offAllNamed(
                MyHomePageRoute(
                  args: HomeArgs(title: 'Message from Second Page'),
                ),
              ),
              child: const Text('Go Back'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
130
points
24
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Type-safe, annotation-based route generation for GetX. Annotate your pages with @AppRoute, run the CLI generator, and get a fully typed AppRouter with type-safe navigation and strongly-typed argument passing. No build_runner required.

Repository (GitHub)
View/report issues
Contributing

Topics

#getx #routing #code-generation #navigation #type-safe

License

MIT (license)

Dependencies

analyzer, flutter, path, yaml

More

Packages that depend on get_typed_router