Prevent frequent flashes
On Android, flashing content often uses Executors, Handler, or Timer. Check if these objects are used to show more than three flashes per second.
If your app contains any videos, also check if these contain more than three flashes per second.
kotlin
private val handler = Handler(Looper.getMainLooper())
private val flashRunnable = object : Runnable {
override fun run() {
toggleFlashing()
handler.postDelayed(this, 333) // Do not do this
}
}
val flashingTextView = findViewById(R.id.flashingTextView)
flashingTextView.text = "Flashing Content"
isFlashing = true
handler.post(flashRunnable) In Jetpack Compose, flashing content often uses LaunchedEffect) with infinite loop, or Timer. Check if these objects are used to show more than three flashes per second.
If your app contains any videos, also check if these contain more than three flashes per second.
kotlin
var isFlashing by remember { mutableStateOf(false) }
val coroutineScope = rememberCoroutineScope()
// Timer to control the flashing rate
// Flash every 1/3 second (3 times per second)
// Do not do this
LaunchedEffect(Unit) {
coroutineScope.launch {
while (true) {
delay(333) // 1/3 second
isFlashing = !isFlashing
}
}
}
Box(
modifier = Modifier
.fillMaxSize()
.background(if (isFlashing) Color.Black else Color.White)
contentAlignment = Alignment.Center
) {
Text(
text = "Flashing Content",
color = if (isFlashing) Color.White else Color.Black
)
} On iOS, flashing content often uses DispatchQueue. Check if this object is used to show more than three flashes per second.
If your app contains any videos, also check if these contain more than three flashes per second.
swift
Not available, contribute! In SwiftUI, flashing content often utilizes DispatchQueue or Timer. Ensure that these objects are not used to create more than three flashes per second.
Additionally, if your app includes any videos, verify that they do not contain more than three flashes per second.
swift
// Timer to control the flashing rate
// Flash every 1/3 second (3 times per second)
let timer = Timer.publish(every: 1 / 3, on: .main, in: .common).autoconnect()
@State private var isFlashing = false
var body: some View {
Text("Flashing Content")
.foregroundColor(isFlashing ? .white : .black)
.background(isFlashing ? .black : .white)
.onReceive(timer) { _ in
isFlashing.toggle()
}
.onAppear {
isFlashing = true
}
} In Flutter, flashing content often uses widgets that change on changes from a Stream. For example, this could happen by using a StreamBuilder, and thus requesting a re-draw of certain parts of the screen. Check if these objects are used to show more than three flashes per second.
If your app contains any videos, also check if these contain more than three flashes per second.
dart
Not available, contribute! In React Native, flashing content might be a result of using Animated or Timers. By default, each animation will take 500 milliseconds. Make sure your animations does not result in more than three flashes per second.
If your app contains any videos, also check if these contain more than three flashes per second.
jsx
setTimeout(() => {
// Avoid three flashes per second
}, 500); In MAUI, flashing content might be a result of using Timer or ViewExtensions for animations. By default, each animation will take 250 milliseconds. Ensure that your animations do not result in more than three flashes per second.
If your app contains any videos, also check if they contain no more than three flashes per second.
csharp
// No code required In Xamarin.Forms, flashing content might be a result of using Timer or ViewExtensions for animations. By default, each animation will take 250 milliseconds. Make sure your animations does not result in more than three flashes per second.
If your app contains any videos, also check if these contain more than three flashes per second.
csharp
Not available, contribute!