9
This commit is contained in:
49
lib/13/go/books/src/screens/author_details.dart
Normal file
49
lib/13/go/books/src/screens/author_details.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../data.dart';
|
||||
import '../widgets/book_list.dart';
|
||||
|
||||
/// The author detail screen.
|
||||
class AuthorDetailsScreen extends StatelessWidget {
|
||||
/// Creates an author detail screen.
|
||||
const AuthorDetailsScreen({
|
||||
required this.author,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// The author to be displayed.
|
||||
final Author? author;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (author == null) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: Text('No author found.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(author!.name),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: BookList(
|
||||
books: author!.books,
|
||||
onTap: (Book book) => context.go('/book/${book.id}'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user