启动应用程序时初始化 CupertinoPicker (flutter)

时间:2021-05-11 06:45:31

标签: flutter android-studio dart cupertinopicker

当我开始在我的设备上调试应用程序时,CupertinoPicker 运行良好,但是当我重新启动应用程序(不是调试)时,即使列表已成功初始化,Cupertino 也没有显示任何内容。 SharedPrefences 在 initState 函数中初始化的列表。 可能是什么原因?

库比蒂诺代码:

Widget buildChosenExeOrRestPicker() => SizedBox(
    height: 170,
    child: CupertinoPicker(
      scrollController: ctrl,
      magnification: 1.3,
      useMagnifier: true,
      itemExtent: 45,
      diameterRatio: 1.1,
      looping: false,
      onSelectedItemChanged: (index) {
        setState(() {
          this.indexOfRes = index;
          
        });
      },
      selectionOverlay: CupertinoPickerDefaultSelectionOverlay(
        background: (pickerExeOrRest.length > 0)
            ? Colors.cyanAccent.withOpacity(0.12)
            : Colors.transparent,
      ),
      children: modelBuilder<PickerExeOrRest>(
        pickerExeOrRest,
        (index, value) {
          final isSelected = this.indexOfRes == index;
          final color = isSelected ? Colors.pink : Colors.black;

          return Center(
            child: Text(
              '${value.time + ', ' + value.name}',
              style: TextStyle(
                  color: color.withOpacity(opacityCupertino), fontSize: 24),
            ),
          );
        },
      ),
    ),
  );

0 个答案:

没有答案
相关问题