mirror of https://github.com/flutter/samples.git
parent
56ff720b61
commit
f58fd1ca1d
@ -0,0 +1,15 @@
|
||||
sealed class Response<T> {
|
||||
const Response();
|
||||
factory Response.ok(T value) => Ok(value);
|
||||
factory Response.error(Exception error) => Error(error);
|
||||
}
|
||||
|
||||
final class Ok<T> extends Response<T> {
|
||||
const Ok(this.value);
|
||||
final T value;
|
||||
}
|
||||
|
||||
final class Error<T> extends Response<T> {
|
||||
const Error(this.error);
|
||||
final Exception error;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
class Destination {
|
||||
Destination({
|
||||
required this.ref,
|
||||
required this.name,
|
||||
required this.country,
|
||||
required this.continent,
|
||||
required this.knownFor,
|
||||
required this.tags,
|
||||
required this.imageUrl,
|
||||
});
|
||||
|
||||
/// e.g. 'alaska'
|
||||
final String ref;
|
||||
|
||||
/// e.g. 'Alaska'
|
||||
final String name;
|
||||
|
||||
/// e.g. 'United States'
|
||||
final String country;
|
||||
|
||||
/// e.g. 'North America'
|
||||
final String continent;
|
||||
|
||||
/// e.g. 'Alaska is a haven for outdoor enthusiasts ...'
|
||||
final String knownFor;
|
||||
|
||||
/// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching']
|
||||
final List<String> tags;
|
||||
|
||||
/// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg'
|
||||
final String imageUrl;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
import 'package:compass_app/common/utils/response.dart';
|
||||
import 'package:compass_app/features/results/business/model/destination.dart';
|
||||
import 'package:compass_app/features/results/data/results_repository.dart';
|
||||
|
||||
class SearchDestinationUsecase {
|
||||
|
||||
final ResultsRepository repository;
|
||||
|
||||
Future<Response<List<Destination>>> search({ String? region }) async {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
import 'package:compass_app/common/utils/response.dart';
|
||||
import 'package:compass_app/features/results/business/model/destination.dart';
|
||||
|
||||
class ResultsRepository {
|
||||
|
||||
Future<Response<List<Destination>>> getDestinations() {
|
||||
// TODO: Load some data
|
||||
return Future.value(Response.ok([]));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue