get 1.8.1 copy "get: ^1.8.1" to clipboard
get: ^1.8.1 copied to clipboard

outdated

A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars easily with no context.

example/lib/main.dart

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

void main() {
  runApp(MaterialApp(
    title: 'Navigation Basics',
    navigatorKey: Get.key,
    home: FirstRoute(),
  ));
}

class FirstRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('First Route'),
      ),
      body: Center(
        child: RaisedButton(
          child: Text('Open route'),
          onPressed: () {
            Get.to(SecondRoute());
          },
        ),
      ),
    );
  }
}

class SecondRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Second Route"),
      ),
      body: Center(
        child: RaisedButton(
          onPressed: () {
            Get.back();
          },
          child: Text('Go back!'),
        ),
      ),
    );
  }
}

class Router {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case '/':
        return GetRoute(
          page: SplashScreen(),
          settings: settings,
        );
      case '/Home':
        return GetRoute(
            settings: settings, page: Home(), transition: Transition.fade);
      case '/Chat':
        return GetRoute(
            settings: settings,
            page: Chat(),
            transition: Transition.rightToLeft);
      default:
        return GetRoute(
            settings: settings,
            transition: Transition.rotate,
            page: Scaffold(
              body:
                  Center(child: Text('No route defined for ${settings.name}')),
            ));
    }
  }
}
15k
likes
0
points
646k
downloads

Publisher

verified publishergetx.site

Weekly Downloads

A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars easily with no context.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on get