Closed nt4f04uNd closed 3 years ago
You have to provide the pattern
for that. In you example, it'll vibrate only once.
@benjamindean so what's the correct code for the behavior i want to achieve?
i still don't understand does intensifies automatically interpolate the vibration values and this code will be correct?
Vibration.vibrate(
duration: duration,
pattern: [0, duration],
intensities: reverse ? const [255, 1] : const [1, 255],
);
or i have to specify all of them
final intensities = List.generate(255, (i) => i + 1);
Vibration.vibrate(
duration: duration,
// generates a pattern [0, 0.4, 0, 0.4, 0, 0.4, 0, 0.4, 0, 0.4, .......... ]
pattern: List.generate(255 * 2, (i) => i).map((el) => el % 2 == 0 ? 0 : duration / 255).toList(),
intensities: reverse ? intensities.reversed.toList() : intensities,
);
which is correct?
upd: it's not really easy to test on real device for me so i'm asking you to explain how this intended to work, and please, explicitly document this, it's not obvious at all
@nt4f04uNd Have you checked the examples in README? You should specify either duration or pattern in milliseconds with intensities list.
@benjamindean yep, i just missed the thing that you have to either use duration and amplitude, or pattern and intensifies
all works fine for me now
but, i now i think you should either add assertions for that, or make another method and move the pattern vibration in there. current api is a little bit confusing imo
i want just to vibrate for a few seconds and all this time that it intensifies friom 1 to 255, or rather, reversely, goes from 255 to 1 from you readme i thought that to perform that i'm supposed to do just that
but it doesn't seem to work and that's confusing
upd: testing on iphone x