From 688fa63da287ccc1bfd46e57dd97d5b0fb0f1515 Mon Sep 17 00:00:00 2001 From: daniel-michel <65034538+daniel-michel@users.noreply.github.com> Date: Mon, 8 Jan 2024 11:56:35 +0100 Subject: [PATCH] refactor --- lib/model/delayed_function_caller.dart | 6 ++---- lib/model/movie_manager.dart | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/model/delayed_function_caller.dart b/lib/model/delayed_function_caller.dart index d439537..46efcba 100644 --- a/lib/model/delayed_function_caller.dart +++ b/lib/model/delayed_function_caller.dart @@ -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); } } diff --git a/lib/model/movie_manager.dart b/lib/model/movie_manager.dart index 07300ea..874ff10 100644 --- a/lib/model/movie_manager.dart +++ b/lib/model/movie_manager.dart @@ -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) {