Asking for additional feature development: combine gesturedetector in roulette_paint.dart file
Hello developers, thanks for your roulette package.
Looking for some way to include either text field or gesture detect widget(or showdialog) in each section of the roulette when clicked.
Since I am very new to flutter and dart, have an idea that some how need to manipulate _drawSections function in roulette_paint.dart file.
I spent a week of research in create a widget in function, but got no feasible solution.
Asking for your help sincerely.
Hope this open project(package) still in progress :)
Sorry, I'm too busy to implement new features recently. But I could propose some suggestions.
gesture detect widget(or showdialog) in each section of the roulette when clicked
Instead of directly set gesture detector in the section, you could try this way:
- Detect the tap gesture's position on the whole roulette.
- Try determine the tapped section according to the division and rotation.
You can find the rotation in the RouletteController's animation property, just use the animation's value, it is in radian.
include text field
This roulette widget is directly drew on the Canvas(just like an image), so putting Widget into it is impossible in my opinion.
Thanks for your reply with suggestions @do9core
But still wonder how to determine the tapped section according to user's behaviour.
For example with above image, how let the application understand if user clicks each specific section.
For more specific instance, if user clicked yellow section of roulette, could the application show a dialog message like 'you have clicked yellow section of the roulette'.
Wrap the roulette widget with gestordetector can resolve your first suggestion which detects the position of the whole roulette.
Should I redraw invisible roulette? or could you give me some other suggestions?
Looking forward your reply :)
To make this easy, Let's just use a 4 parts roulette. Think about this example:
Actually, the part i(i from 0) of the n parts roulette has the range of:
[rotation + i * 2pi / n, rotation + (i + 1) * 2pi / n)
for example, the part 1 of 4 in the example has i = 0, so its range is:
[rotation + 0 * 2pi / 4, rotation + 1 * 2pi / 4)
which is [rotation, rotation + pi / 2)
With the algorithm above, what you need to do is calculate the θ value and check which part it is in.