基础库
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

page_factory.dart 1.0 KiB

4 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. typedef Widget CreatePage(Map<String, dynamic> model);
  4. /* 页面生成工厂, 用于生成flutter端公共跳转页面,native端页面生成PlatforView等等 */
  5. class PageFactory {
  6. static Map<String, CreatePage> pageCreater = Map();
  7. /**
  8. * @description: 注册路由
  9. * @param {name} SkipUIIdentifier
  10. * @return:
  11. */
  12. static void regist(String name, CreatePage creater) {
  13. if (pageCreater.containsKey(name)) {
  14. return;
  15. }
  16. pageCreater[name] = creater;
  17. }
  18. /**
  19. * @description: 创建页面
  20. * @param {String} name注册的SkipUIIdentifier
  21. * @return:
  22. */
  23. static Widget create(String name, Map<String, dynamic> model) {
  24. if (pageCreater.containsKey(name)) {
  25. return pageCreater[name](model);
  26. }
  27. return EmptyPage();
  28. }
  29. /**
  30. * @description: 是否注册页面
  31. * @param {bool}
  32. * @return:
  33. */
  34. static bool hasRegisted(String name) {
  35. return pageCreater.containsKey(name);
  36. }
  37. }