1

I have a UI like

image

Now I want to create the letters on circle by given data. I need it to be a dynamic, when letters are less, (like 3 or 4) they must be far from each other. But, when they many (10 or 12) they must fit to circle (must have dynamic size and dynamic position). The code of circle and letters -

Container(
            width: SizeConfig.devWidth! * 0.6,
            height: SizeConfig.devHeight! * 0.35,
            decoration: BoxDecoration(
              border: Border.all(color: Colors.blue),
              color: MyColors.nextButtonColor,
              shape: BoxShape.circle,
            ),
            child: Stack(
              alignment: Alignment.center,
              children: [
                Positioned(
                    top: SizeConfig.devHeight! * 0.04,
                    child: isDragging == true && isItemsDragging[0] != true
                        ? dragTargetWidget('Č', 0)
                        : draggableWord('Č', 0)),
                Positioned(
                    top: SizeConfig.devHeight! * 0.07,
                    right: SizeConfig.devWidth! * 0.1,
                    child: isDragging == true && isItemsDragging[1] != true
                        ? dragTargetWidget('É', 1)
                        : draggableWord('É', 1)),
                Positioned(
                    right: SizeConfig.devWidth! * 0.03,
                    child: isDragging == true && isItemsDragging[2] != true
                        ? dragTargetWidget('Ž', 2)
                        : draggableWord('Ž', 2)),
                Positioned(
                    bottom: SizeConfig.devHeight! * 0.07,
                    right: SizeConfig.devWidth! * 0.1,
                    child: isDragging == true && isItemsDragging[3] != true
                        ? dragTargetWidget('U', 3)
                        : draggableWord('U', 3)),
                Positioned(
                    bottom: SizeConfig.devHeight! * 0.04,
                    child: isDragging == true && isItemsDragging[4] != true
                        ? dragTargetWidget('T', 4)
                        : draggableWord('T', 4)),
                Positioned(
                    bottom: SizeConfig.devHeight! * 0.07,
                    left: SizeConfig.devWidth! * 0.1,
                    child: isDragging == true && isItemsDragging[5] != true
                        ? dragTargetWidget('Ě', 5)
                        : draggableWord('Ě', 5)),
                Positioned(
                    left: SizeConfig.devWidth! * 0.03,
                    child: isDragging == true && isItemsDragging[6] != true
                        ? dragTargetWidget('А', 6)
                        : draggableWord('А', 6)),
                Positioned(
                    top: SizeConfig.devHeight! * 0.07,
                    left: SizeConfig.devWidth! * 0.1,
                    child: isDragging == true && isItemsDragging[7] != true
                        ? dragTargetWidget('K', 7)
                        : draggableWord('K', 7)),
              ],
            ))
      ],
    ),
  ),

and my data is -

Crossword(type: "crossword", format: [
  "      š",
  "    žák",
  "      o",
  " učitel",
  "      a"
], chars: [
  "i",
  "e",
  "l",
  "a",
  "t",
  "o",
  "č",
  "k",
  "š",
  "á",
  "u",
  "ž"
], strings: {
  "škola": ["      *", "      *", "      *", "      *", "      *"],
  "žák": ["       ", "    ***", "       ", "       ", "       "],
  "učitel": ["       ", "       ", "       ", " ******", "       "]
}),

Any idea how can I achieve this? Any solution would be very useful, thanks!

4
  • see RotaryDialDelegate - it is used as a delegate: for CustomMultiChildLayout Commented Sep 19, 2021 at 5:09
  • @pskink ok, I will try it, thank you Commented Sep 19, 2021 at 5:13
  • @pskink thank you so much!!! Write your answer please, It'll be a correct answer! Commented Sep 19, 2021 at 6:36
  • your welcome, write a self answer then ;-) Commented Sep 19, 2021 at 6:44

1 Answer 1

1

Thanks to @pskink! The solution is to use RotaryDialDelegate as a delegate for CustomMultiChildLayout. Check the code below:

Container(
            width: SizeConfig.devWidth! * 0.6,
            height: SizeConfig.devHeight! * 0.35,
            decoration: BoxDecoration(
              border: Border.all(color: Colors.blue),
              color: MyColors.nextButtonColor,
              shape: BoxShape.circle,
            ),
            child: CustomMultiChildLayout(
              delegate: RotaryDialDelegate(
                  wowProv.crosswordExercises[widget.indexLevel!].chars!.length),
              children: dragLetters
            ))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.