Closed huangshan-ios closed 3 years ago
Hi @huangshan-ios, I can't reproduce this issue on my end as the intention of having a stream for selecting values originally was to enable this feature.
Can you please share a minimum reproducible code sample, where I can check the issue?
Hi @kevlatus,
I have a RxInt currentSliceIndex
for the stream
FortuneWheel(
rotationCount: 20,
selected: currentSliceIndex.stream,
items: currentSpin.slices.map((slice) => FortuneItem(
style: FortuneItemStyle(
borderColor: Colors.transparent,
color: slice.color,
),
child: Text(slice.title),
))
.toList(),
animateFirst: false,
onAnimationEnd: () {},
onFling: () {},
)
and I have a function to set the currentSliceIndex
currentSliceIndex.value = Random().nextInt(currentSpin.slices.length);
But if the Random.nextInt()
returns the same value 2 times in a row ( Ex: The first time is 1, and the second is 1 too). The wheel receives the stream but it doesn't do anything.
hey @huangshan-ios,
please try the following code, which does use built-in features from Flutter. This works as intended on my end. If it does on your end, I guess the issue is to be found in the RxInt feature you are using,
class ExamplePage extends StatefulWidget {
@override
_ExamplePageState createState() => _ExamplePageState();
}
class _ExamplePageState extends State<ExamplePage> {
StreamController<int> selected = StreamController<int>();
@override
void dispose() {
selected.close();
super.dispose();
}
@override
Widget build(BuildContext context) {
final items = <String>[
'Grogu',
'Mace Windu',
'Obi-Wan Kenobi',
'Han Solo',
'Luke Skywalker',
'Darth Vader',
'Yoda',
'Ahsoka Tano',
];
return Scaffold(
appBar: AppBar(
title: Text('Flutter Fortune Wheel'),
),
body: GestureDetector(
onTap: () {
selected.add(0);
},
child: Column(
children: [
Expanded(
child: FortuneWheel(
selected: selected.stream,
items: [
for (var it in items) FortuneItem(child: Text(it)),
],
),
),
],
),
),
);
}
}
Hi @kevlatus, Thank you for your support. I'll give it a try and close this issue.
Is your feature request related to a problem? Please describe. I don't really know whether this is a bug or just not implemented feature. But I've implemented a wheel, and when the stream of selected is receiving the same as the previous value, it's doesn't start the animation or anything.
Describe the solution you'd like I think the wheel can provide a init bool for turning on/off this feature.
Describe alternatives you've considered Please consider the above solution.
Additional context Ex: The first time the selected is receiving 1, and the second time it's receiving 1 again. The wheel will not start running or anything.
version: flutter_fortune_wheel: ^1.1.0