psk907 / fluttermoji

A light-weight and highly customizable SVG graphic set for Flutter which generates avatars and provides a Customizer Widget, personalized CircleAvatar and other utility functions.
https://pub.dev/packages/fluttermoji
MIT License
72 stars 50 forks source link

Background Color #5

Open davidcantonnadales opened 3 years ago

davidcantonnadales commented 3 years ago

Can export the background color with the rest of SVG items?

Thanks

psk907 commented 3 years ago

@gaznerviozzo can you please elaborate on this?

davidcantonnadales commented 3 years ago

Oh yes sorry for the short description.

I added a background color selector:

image

But when i save the avatar, background color is not exported with the rest of the avatar:

image

I think the backgroundColor property of the CircleAvatar is not valid

          Padding(
                padding: const EdgeInsets.symmetric(vertical: 30),
                child: FluttermojiCircleAvatar(
                  backgroundColor: currentColor,
                  radius: 100,
                ),
              ),
psk907 commented 3 years ago

When you save, the setFluttermoji() function is called on the FluttermojiController, here we will encode the selectedIndexes Map and store it as a string using shared preferences under the key: fluttermojiSelectedOptions .

If the background color attribute you've added is not being saved, it's most likely because you aren't actually saving it in the first place , in a map that looks like this -

{
  'backgroundColor': <value>,
  'topType': 24,
  'accessoriesType': 0,
  'hairColor': 1,
  'facialHairType': 0,
  'facialHairColor': 1,
  'clotheType': 4,
  'eyeType': 6,
  'eyebrowType': 10,
  'mouthType': 8,
  'skinColor': 3,
  'clotheColor': 8,
  'style': 0,
  'graphicType': 0
}

You should also update the fluttermojiProperties and defaultFluttermojiOptions in order to use background color as a part of the SVG.

These steps are needed as the above variables are define the whole structure of the fluttermoji.