import 'package:flutter/material.dart';
import 'dart:ui';
class PopShow extends PopupRoute {
final Duration _duration = Duration(milliseconds: 300);
PopShow({Key ? key});
static pop(BuildContext context) {
// _CustomPopRouteViewState.of(context).dismiss();
print("pop 了页面");
Navigator.of(context).pop();
}
@override
Color get barrierColor => Colors.transparent;
@override
bool get barrierDismissible => false;
@override
String get barrierLabel => "";
@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return CustomPopRouteView();
}
@override
Duration get transitionDuration => _duration;
}
class CustomPopRouteView extends StatefulWidget {
CustomPopRouteView({Key? key}) : super(key: key);
@override
State<CustomPopRouteView> createState() => _CustomPopRouteViewState();
}
class _CustomPopRouteViewState extends State<CustomPopRouteView> {
@override
void initState() {
print("开始创建");
super.initState();
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: (){
Navigator.pop(context);
},
child: Container(
// color: Colors.blue,
child: Text("123"),
),
);
}
}
使用
Navigator.push(context, PopShow());
网友评论