Pyozer / flutter_material_color_picker

Material color picker, you can customize colors. Selection in two step, first main color and after shades.
https://pub.dartlang.org/packages/flutter_material_color_picker
MIT License
75 stars 38 forks source link

Color Expansion: No Shades available #18

Open Nexushunter opened 5 years ago

Nexushunter commented 5 years ago

Hey, so I've noticed that selecting shades in not available when the colour selector is in an ExpansionTile. Not 100% certain if you may have noticed this when using the package, it may very well be my set up that has the issue. Thanks in advance for taking the time :smile:

Here's how I've currently set it up in my project:

_colorSelector(String title, Settings prefs, String attr) {
    return ExpansionTile(
      title: Text.rich(
        TextSpan(
          text: title,
        ),
      ),
      children: <Widget>[
        _generateColor(_getColor(attr), prefs),
      ],
      trailing: CircleColor(
        color: prefs.colors[_getColor(attr)],
        circleSize: 25 * (prefs.scale / 2),
      ),
    );
  }

What generate color does :

_generateColor(int colorSetting, Settings prefs) {
    return MaterialColorPicker(
      allowShades: true,
      circleSize: 75 * (prefs.scale),
      onColorChange: (Color color) {
        prefs.themeData = ThemeData(
            primaryColor: (colorSetting == 0) ? color : prefs.colors[0],
            primarySwatch: (colorSetting == 0)
                ? MaterialColor(
                    color.value,
                    toSwatch(color.value),
                  )
                : MaterialColor(
                    prefs.colors[0].value,
                    toSwatch(prefs.colors[0].value),
                  ),
            brightness: (prefs.darkMode) ? Brightness.dark : Brightness.light,
            accentColor: (colorSetting == 1) ? color : prefs.colors[1],
            accentColorBrightness: prefs.themeData.accentColorBrightness,
            splashColor: (colorSetting == 2) ? color : prefs.colors[2]);
      },
      // onMainColorChange: (ColorSwatch color) {
      //   prefs.themeData = ThemeData(
      //       primaryColor: (colorSetting == 0) ? color : prefs.colors[0],
      //       primarySwatch: (colorSetting == 0)
      //           ? MaterialColor(
      //               color.value,
      //               toSwatch(color.value),
      //             )
      //           : MaterialColor(
      //               prefs.colors[0].value, toSwatch(prefs.colors[0].value)),
      //       brightness: (prefs.darkMode) ? Brightness.dark : Brightness.light,
      //       accentColor: (colorSetting == 1) ? color : prefs.colors[1],
      //       accentColorBrightness: prefs.themeData.accentColorBrightness,
      //       splashColor: (colorSetting == 2) ? color : prefs.colors[2]);
      // },
      selectedColor: prefs.colors[colorSetting],
    );
  }