GanZhiXiong/gzx_dropdown_menu

多个实例加载时报错

wishinlife opened this issue · 1 comments

主页用IndexedStack同时加载多个页面,当有两个或以上页面使用此插件时报错:
======== Exception caught by widgets library =======================================================
The following LateError was thrown building GZXDropDownMenu(dirty, dependencies: [_EffectiveTickerMode, MediaQuery], state: _GZXDropDownMenuState#f2693(ticker inactive)):
LateInitializationError: Field '_maskColorOpacity@969011985' has not been initialized.

The relevant error-causing widget was:
GZXDropDownMenu file:///D:/Sky-Eye/code/skyeye-app-flutter/trunk/lib/page/home/tab_alert.dart:393:15
When the exception was thrown, this was the stack:
#0 _GZXDropDownMenuState._maskColorOpacity (package:gzx_dropdown_menu/src/gzx_dropdown_menu.dart)
#1 _GZXDropDownMenuState._mask (package:gzx_dropdown_menu/src/gzx_dropdown_menu.dart:176:47)
#2 _GZXDropDownMenuState._buildDropDownWidget (package:gzx_dropdown_menu/src/gzx_dropdown_menu.dart:206:13)
#3 _GZXDropDownMenuState.build (package:gzx_dropdown_menu/src/gzx_dropdown_menu.dart:86:12)
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4612:27)

每个页面的key和GZXDropdownMenuController都是独立的,不知道为什么报这个错误。

找到原因了,是我在切换页面时调用_dropdownMenuController.hide();没有判断是否已显示造成的。