frostrouter 0.9.2 copy "frostrouter: ^0.9.2" to clipboard
frostrouter: ^0.9.2 copied to clipboard

FrostRouter is a library that helps you move from one page to another in Flutter projects.

example/lib/main.dart

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

final frostrouter = FrostRouter([
  FrostRoute(name: 'homepage', path: '/', builder: (context) => HomePage()),
  FrostRoute(
    name: 'SecondaryPage',
    path: '/secondary',
    builder: (context) => SecondaryPage(),
  ),
  FrostRoute(
    name: 'TertileryPage',
    path: '/tertilery',
    builder: (context) => TertileryPage(),
  ),
]);

void main() {
  runApp(MaterialApp.router(routerConfig: frostrouter.config));
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('HomePage'), centerTitle: true),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRouteName('SecondaryPage');
              },
              child: Text('Name Go Second Page'),
            ),
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRoutePath('/secondary');
              },
              child: Text('Path Go Second Page'),
            ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('SecondaryPage'), centerTitle: true),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRouteName('TertileryPage');
              },
              child: Text('Name Go TertileryPage'),
            ),
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRoutePath('/tertilery');
              },
              child: Text('Path Go TertileryPage'),
            ),
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRoutePop();
              },
              child: Text('Pop Home Page'),
            ),
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRouteReturn();
              },
              child: Text('Return Home Page'),
            ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('TertileryPage'), centerTitle: true),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRouteName('homepage');
              },
              child: Text('Name Go Home Page'),
            ),
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRoutePath('/');
              },
              child: Text('Path Go Home Page'),
            ),
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRoutePop();
              },
              child: Text('Pop SecondaryPage'),
            ),
            ElevatedButton(
              onPressed: () {
                frostrouter.frostRouteReturn();
              },
              child: Text('Return SecondaryPage'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
40
downloads

Publisher

verified publisherfrostaloncode.blogspot.com

Weekly Downloads

FrostRouter is a library that helps you move from one page to another in Flutter projects.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on frostrouter