rydmike / flex_color_picker

A highly customizable Flutter color picker.
BSD 3-Clause "New" or "Revised" License
200 stars 42 forks source link

Wheel with enableTonalPalette -> LateInitializationError: Field '_activeColorSwatchList@1082511434' has not been initialized. #71

Closed te8uekm12 closed 10 months ago

te8uekm12 commented 10 months ago

To reproduce the problem you need to modify example from: https://pub.dev/packages/flex_color_picker/example with

class _ColorPickerPageState extends State<ColorPickerPage> {
...
@override
  void initState() {
    ...
    dialogPickerColor = const Color(0xFF613E42); \\ Set custom color to force wheel
    ...
   }

   ...
  Future<bool> colorPickerDialog() async {
    return ColorPicker(
    ...
    enableTonalPalette: true, \\Enable tonal palete
    ...
    ).showPickerDialog(
     ...
    );
   }
}

Then you have to:

======== Exception caught by widgets library =======================================================
The following LateError was thrown building ColorPicker(dirty, state: _ColorPickerState#a56bf):
LateInitializationError: Field '_activeColorSwatchList@1082511434' has not been initialized.

The relevant error-causing widget was: 
  ColorPicker ColorPicker:file:///D:/workspace/mobile/ex_app/lib/ag/main.dart:255:12
When the exception was thrown, this was the stack: 
#0      _ColorPickerState._activeColorSwatchList (package:flex_color_picker/src/color_picker.dart)
#1      _ColorPickerState.build (package:flex_color_picker/src/color_picker.dart:1709:42)
#2      StatefulElement.build (package:flutter/src/widgets/framework.dart:5583:27)
#3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5471:15)
#4      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#5      Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#6      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2895:19)
#7      WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:984:21)
rydmike commented 10 months ago

Hi @te8uekm12,

Thanks for this report and sorry for the delay. I have verified the bug, identified the bug cause and made a fix. I just need to test and verify it a bit more. I should be able to release the fix later today.

rydmike commented 10 months ago

The bug is fixed, but the package is not released yet. GitHub auto closes an issues with a FIX is mentioned that references and issue. I re-opened the issue and will close it manually when the updated package that contains the fix has actually been released on pub.

rydmike commented 10 months ago

Version 3.3.1 with the fix has been released.

te8uekm12 commented 10 months ago

Works great, thanks for help:)