1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-18 12:59:04 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -23,10 +23,11 @@ class BookingApi {
BookingApi() {
// Create a default booking
final destination = Assets.destinations.first;
final activitiesRef = Assets.activities
.where((activity) => activity.destinationRef == destination.ref)
.map((activity) => activity.ref)
.toList();
final activitiesRef =
Assets.activities
.where((activity) => activity.destinationRef == destination.ref)
.map((activity) => activity.ref)
.toList();
_bookings.add(
Booking(
id: _sequentialId++,
@@ -60,8 +61,9 @@ class BookingApi {
// Get a booking by id
router.get('/<id>', (Request request, String id) {
final bookingId = int.parse(id);
final booking =
_bookings.firstWhereOrNull((booking) => booking.id == bookingId);
final booking = _bookings.firstWhereOrNull(
(booking) => booking.id == bookingId,
);
if (booking == null) {
return Response.notFound('Invalid id');
@@ -81,7 +83,8 @@ class BookingApi {
if (booking.id != null) {
// POST endpoint only allows newly created bookings
return Response.badRequest(
body: 'Booking already has id, use PUT instead.');
body: 'Booking already has id, use PUT instead.',
);
}
// Add ID to new booking
@@ -101,8 +104,9 @@ class BookingApi {
// Delete booking
router.delete('/<id>', (Request request, String id) async {
final bookingId = int.parse(id);
final booking =
_bookings.firstWhereOrNull((booking) => booking.id == bookingId);
final booking = _bookings.firstWhereOrNull(
(booking) => booking.id == bookingId,
);
if (booking == null) {
return Response.notFound('Invalid id');
}

View File

@@ -21,9 +21,10 @@ class DestinationApi {
});
router.get('/<id>/activity', (Request request, String id) {
final list = Assets.activities
.where((activity) => activity.destinationRef == id)
.toList();
final list =
Assets.activities
.where((activity) => activity.destinationRef == id)
.toList();
return Response.ok(
json.encode(list),
headers: {'Content-Type': 'application/json'},

View File

@@ -33,10 +33,7 @@ class LoginApi {
loginRequest.password == Constants.password) {
return Response.ok(
json.encode(
LoginResponse(
token: Constants.token,
userId: Constants.userId,
),
LoginResponse(token: Constants.token, userId: Constants.userId),
),
headers: {'Content-Type': 'application/json'},
);