import 'movie.dart'; import 'genre.dart'; import 'dart:math'; class MovieGenerator { final int count; MovieGenerator({required this.count}); Future> generateMoviesWithDelay() async { await Future.delayed(Duration(seconds: 2)); final random = Random(); return List.generate(count, (index) { final title = 'Movie ${index + 1}'; final genre = Genre.values[random.nextInt(Genre.values.length)]; final rating = random.nextDouble() * 10; return Movie(title: title, genre: genre, rating: rating); }); } List sortMovies(List movies) { return movies..sort((a, b) => b.rating.compareTo(a.rating)); } }