global_web_page.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'package:flutter/material.dart';
  2. import 'package:plugin_basic/router/basic_page_router.dart';
  3. import 'package:shared/utils/log_utils.dart';
  4. import 'package:hooks_riverpod/hooks_riverpod.dart';
  5. import '../widget/webview_page.dart';
  6. import 'package:auto_route/auto_route.dart';
  7. /*
  8. * 全局的公共Web页面
  9. */
  10. @RoutePage()
  11. class GlobalWebPage extends HookConsumerWidget {
  12. final bool isShowAppBar;
  13. final String initialUrl;
  14. final String title;
  15. const GlobalWebPage({
  16. Key? key,
  17. @PathParam('isShowAppBar') required this.isShowAppBar,
  18. @PathParam('initialUrl') required this.initialUrl,
  19. @PathParam('title') required this.title,
  20. }) : super(key: key);
  21. //启动当前页面
  22. static void startInstance({
  23. required BuildContext context,
  24. required String title,
  25. required String url,
  26. bool isShowAppBar = true,
  27. }) {
  28. context.router.push(GlobalWebPageRoute(isShowAppBar: isShowAppBar, initialUrl: url, title: title));
  29. }
  30. @override
  31. Widget build(BuildContext context, WidgetRef ref) {
  32. Log.d("GlobalWebPage 的参数 isShowAppBar:$isShowAppBar title:$title initialUrl:$initialUrl ");
  33. return WebViewPage(
  34. showAppbar: isShowAppBar,
  35. initialUrl: initialUrl,
  36. arguments: {'title': title},
  37. );
  38. }
  39. }