Skip to content

Instantly share code, notes, and snippets.

@ampersanda
Created September 1, 2019 16:32
Show Gist options
  • Save ampersanda/64e639226f08ddc17f8607aae3a91eea to your computer and use it in GitHub Desktop.
Save ampersanda/64e639226f08ddc17f8607aae3a91eea to your computer and use it in GitHub Desktop.
simple flutter navigator replacement with widget class
import 'package:flutter/cupertino.dart';
class RouterNavigator {
RouterNavigator._();
static Future<T> push<T>(BuildContext context,
{Widget widget,
String title,
bool fullscreenDialog = false,
maintainState = true}) async {
return await Navigator.push(
context,
CupertinoPageRoute(
builder: (_context) => widget,
title: title,
maintainState: maintainState,
fullscreenDialog: fullscreenDialog));
}
static Future<T> pushAndRemoveUntil<T>(BuildContext context,
{Widget widget,
String title,
bool fullscreenDialog = false,
maintainState = true}) async {
return await Navigator.pushAndRemoveUntil(
context,
CupertinoPageRoute(
builder: (_context) => widget,
title: title,
maintainState: maintainState,
fullscreenDialog: fullscreenDialog),
(_) => false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment