refactor
parent
f9a0482e3c
commit
688fa63da2
|
@ -1,7 +1,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
class DelayedFunctionCaller {
|
||||
final Function function;
|
||||
final void Function() function;
|
||||
final Duration duration;
|
||||
Timer? _timer;
|
||||
|
||||
|
@ -14,8 +14,6 @@ class DelayedFunctionCaller {
|
|||
}
|
||||
|
||||
// Create a timer that calls the function after the specified duration.
|
||||
_timer = Timer(duration, () {
|
||||
function();
|
||||
});
|
||||
_timer = Timer(duration, function);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ class MovieManager extends ChangeNotifier {
|
|||
void _insertMovie(MovieData movie) {
|
||||
int min = 0;
|
||||
int max = movies.length - 1;
|
||||
while (min - 1 < max) {
|
||||
int center = ((min + max) / 2).floor();
|
||||
while (min <= max) {
|
||||
int center = (min + max) ~/ 2;
|
||||
int diff =
|
||||
movie.releaseDate.date.compareTo(movies[center].releaseDate.date);
|
||||
if (diff < 0) {
|
||||
|
|
Loading…
Reference in New Issue