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