import 'package:douyin_demo/pages/home_page.dart'; import 'package:douyin_demo/pages/recommend_page.dart'; import 'package:douyin_demo/pages/splash_page.dart'; import 'package:flutter/material.dart'; class Routes { static const home = 'app://'; static const splash = 'app://splash'; static const recommend = "app://recommend"; static define() => { home: (context) => const HomePage(), splash: (context) => const SplashPage(), recommend: (context) => const RecommendPage( selIndex: 0, ), }; Routes.pushNamed(BuildContext context, String url, dynamic params) { _getPage(context, url, params: params); } Routes.pushNamedNoParams(BuildContext context, String url) { _getPage(context, url); } /// 比如splashPage跳转 Routes.popAndPushNamed(BuildContext context, String url) { Navigator.of(context).popAndPushNamed(url); } _getPage(BuildContext context, String url, {dynamic params}) { if (url.startsWith('https://') || url.startsWith('http://')) { // return WebViewPage(url, params: params); } else { if (params == null) { Navigator.pushNamed(context, url); } else { Navigator.pushNamed(context, url, arguments: params); } } } }