import 'package:flutter/material.dart';
import 'package:kdbflutter/common/IGenericDataProvider.dart';
//页面跳转
class RouteUtil {
//跳转页面
static push(BuildContext context, Widget widget) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => widget,
),
);
}
//跳转页面带参
static pushData<T>(BuildContext context, Widget widget, T data) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => IGenericDataProvider<T>(
child: widget,
data: data,
)),
);
}
//跳转并关闭当前页面
static pushAndRemoveUntil(BuildContext context, Widget widget) {
Navigator.pushAndRemoveUntil(
context,
new MaterialPageRoute(builder: (context) => widget),
(route) => route == null,
);
}
//关闭当前页面
static pop(BuildContext context) {
Navigator.pop(context);
}
}