@@ -330,7 +330,16 @@ class _AppInfoPage_AppConfState extends State<AppInfoPage_AppConf> {
330330
331331 /*------------------------------------------------------------*/
332332
333- /*-----------------------环境变量部分-------------------------*/
333+ /*-----------------------环境变量部分-------------------------*/
334+
335+ // 页面构建时获取对应应用环境变量
336+ // 强制非空防止UI构建时出现异常
337+ Map < String , String > env_global_build = env_global ?? {};
338+ Map < String , String > env_app_build = env_app ?? {};
339+
340+ /*------------------------------------------------------------*/
341+
342+ /*-----------------------UI界面构建部分-----------------------*/
334343
335344 /*------------------------------------------------------------*/
336345
@@ -456,36 +465,29 @@ class _AppInfoPage_AppConfState extends State<AppInfoPage_AppConf> {
456465 ),
457466 // 检查全局变量是否为空
458467 // 根据这个合理提示的UI渲染与提示
459- env_global != null
460- ? env_global! .isEmpty
461- ? Text (
462- '暂无' ,
463- style: TextStyle (
464- fontSize: 18 ,
465- ),
466- )
467- : SizedBox .shrink ()
468- : Text (
468+ env_global_build.isEmpty
469+ ? Text (
469470 '暂无' ,
470471 style: TextStyle (
471472 fontSize: 18 ,
472473 ),
473- ),
474+ )
475+ : SizedBox .shrink ()
474476 ],
475477 ),
476478 const SizedBox (height: 5 ,),
477479 ListView .builder (
478480 shrinkWrap: true ,
479481 // 禁止子列表滚动
480482 physics: NeverScrollableScrollPhysics (),
481- itemCount: env_global == null
483+ itemCount: env_global_build.isEmpty
482484 ? 0
483- : env_global ! .length,
485+ : env_global_build .length,
484486 itemBuilder: (context, index) {
485487 return AppInfoPage_EnvWidget_Global (
486488 curIndex: index,
487- curKey: env_global ! .keys.elementAt (index),
488- curValue: env_global ! .values.elementAt (index),
489+ curKey: env_global_build .keys.elementAt (index),
490+ curValue: env_global_build .values.elementAt (index),
489491 );
490492 },
491493 ),
@@ -508,11 +510,7 @@ class _AppInfoPage_AppConfState extends State<AppInfoPage_AppConf> {
508510 // 已经新建了键为''的变量
509511 // 若新建了不能再让用户急需创建, 防止污染字典
510512 canPress: ValueNotifier <bool >(
511- env_app == null
512- ? true
513- : env_app! .containsKey ('' )
514- ? false
515- : true ,
513+ ! env_app_build.containsKey ('' ),
516514 ),
517515 onPressed: () async {
518516 await ConfigEnv_createItem ();
@@ -522,43 +520,39 @@ class _AppInfoPage_AppConfState extends State<AppInfoPage_AppConf> {
522520 ],
523521 ),
524522 const SizedBox (height: 5 ,),
525- env_app != null
526- ? env_app! .isNotEmpty
527- ? ListView .builder (
528- shrinkWrap: true ,
529- // 禁止子列表滚动
530- physics: NeverScrollableScrollPhysics (),
531- itemCount: env_app == null
532- ? 0
533- : env_app! .length,
534- itemBuilder: (context, index) {
535- // 处理Flutter的BUG引起的ListView.builder
536- // 提早加载的问题
537- try {
538- return AppInfoPage_EnvWidget_App (
539- curIndex: index,
540- curKey: env_app! .keys.elementAt (index),
541- curValue: env_app! .values.elementAt (index),
542- textctl_env_name: textctl_env_name_list[index],
543- textctl_env_value: textctl_env_value_list[index],
544- updateEnvKey: (curIndex, newKey) async {
545- return await ConfigEnv_updateKey (curIndex, newKey);
546- },
547- updateEnvValue: (curIndex, newValue) async {
548- await ConfigEnv_updateValue (curIndex, newValue);
549- },
550- deleteEnvItem: (curIndex) async {
551- await ConfigEnv_deleteItem (curIndex);
552- },
553- );
554- }
555- catch (e) {
556- return SizedBox .shrink ();
557- }
558- },
559- )
560- : SizedBox .shrink ()
561- : SizedBox .shrink (),
523+ env_app_build.isNotEmpty
524+ ? ListView .builder (
525+ shrinkWrap: true ,
526+ // 禁止子列表滚动
527+ physics: NeverScrollableScrollPhysics (),
528+ itemCount: env_app_build.length,
529+ itemBuilder: (context, index) {
530+ // 处理Flutter的BUG引起的ListView.builder
531+ // 提早加载的问题
532+ try {
533+ return AppInfoPage_EnvWidget_App (
534+ curIndex: index,
535+ curKey: env_app_build.keys.elementAt (index),
536+ curValue: env_app_build.values.elementAt (index),
537+ textctl_env_name: textctl_env_name_list[index],
538+ textctl_env_value: textctl_env_value_list[index],
539+ updateEnvKey: (curIndex, newKey) async {
540+ return await ConfigEnv_updateKey (curIndex, newKey);
541+ },
542+ updateEnvValue: (curIndex, newValue) async {
543+ await ConfigEnv_updateValue (curIndex, newValue);
544+ },
545+ deleteEnvItem: (curIndex) async {
546+ await ConfigEnv_deleteItem (curIndex);
547+ },
548+ );
549+ }
550+ catch (e) {
551+ return SizedBox .shrink ();
552+ }
553+ },
554+ )
555+ : SizedBox .shrink ()
562556 ],
563557 ),
564558 ),
0 commit comments