基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

53 lines
1.3 KiB

  1. /*
  2. * @Author: Weller
  3. * @Date: 2020-05-16 17:26:40
  4. * @LastEditTime: 2020-06-16 15:40:43
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /hairuyi_flutter_comm/lib/router/page_factory.dart
  8. */
  9. import 'package:flutter/material.dart';
  10. import 'package:zhiying_comm/zhiying_comm.dart';
  11. typedef Widget CreatePage(Map<String, dynamic> model);
  12. /* 页面生成工厂, 用于生成flutter端公共跳转页面,native端页面生成PlatforView等等 */
  13. class PageFactory {
  14. static Map<String, CreatePage> pageCreater = Map();
  15. /**
  16. * @description: 注册路由
  17. * @param {name} SkipUIIdentifier
  18. * @return:
  19. */
  20. static void regist(String name, CreatePage creater) {
  21. if (pageCreater.containsKey(name)) {
  22. return;
  23. }
  24. pageCreater[name] = creater;
  25. }
  26. /**
  27. * @description: 创建页面
  28. * @param {String} name注册的SkipUIIdentifier
  29. * @return:
  30. */
  31. static Widget create(String name, Map<String, dynamic> model) {
  32. if (pageCreater.containsKey(name)) {
  33. return pageCreater[name](model);
  34. }
  35. return EmptyPage();
  36. }
  37. /**
  38. * @description: 是否注册页面
  39. * @param {bool}
  40. * @return:
  41. */
  42. static bool hasRegisted(String name) {
  43. return pageCreater.containsKey(name);
  44. }
  45. }