ui_router 1.0.3 copy "ui_router: ^1.0.3" to clipboard
ui_router: ^1.0.3 copied to clipboard

outdated

Super Simple, Minimal, Lightweight Router. Easy to use and organize the pages on your application.

example/main.dart

import 'package:flutter/material.dart';
import 'package:ui_router/ui_router.dart';

void main() {
  runApp(App());
}

//
//  'String' or 'Enum' , any type Page ID
//
enum Pages {
  A,
  B,
}

//
//  router
//
final router = UiRouter(
  initialPageId: Pages.A,
  pages: [
    //
    // Add all pages here.
    //
    UiPage(
      id: Pages.A,
      build: (params) => PageA(),
    ),
    UiPage(
      id: Pages.B,
      build: (params) => PageB(params['message']),
    ),
  ],
);

//
//  Your App
//
class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //
      //  Display as a Widget
      //
      home: router.widget(),
    );
  }
}

//
//  Page A
//
class PageA extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('This is A')),
      body: ElevatedButton(onPressed: pushToB, child: Text('Push To B')),
    );
  }

  pushToB() {
    router.push(Pages.B, params: {'message': 'HELLO😁'});
  }
}

//
//  Page B
//
class PageB extends StatelessWidget {
  final String? message;
  PageB(this.message);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('This is B')),
      body: Text('received message: $message'),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

verified publisherflut.rbdog.biz

Super Simple, Minimal, Lightweight Router. Easy to use and organize the pages on your application.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on ui_router