Course Catalog
Loading preview
Starting the Flutter app
A showcase of Flutter's course catalog functionality
import 'package:flutter/material.dart';
const _courses = [
{'title': 'Flutter Fundamentals', 'instructor': 'Jane Doe', 'rating': 4.8, 'hours': 12},
{'title': 'Dart Deep Dive', 'instructor': 'John Smith', 'rating': 4.6, 'hours': 8},
{'title': 'State Management', 'instructor': 'Sarah Lee', 'rating': 4.9, 'hours': 6},
{'title': 'Firebase Integration', 'instructor': 'Mike Brown', 'rating': 4.5, 'hours': 10},
];
class CourseCatalog extends StatelessWidget {
const CourseCatalog({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Course Catalog')),
body: GridView.builder(
padding: const EdgeInsets.all(16),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: MediaQuery.of(context).size.width > 600 ? 3 : 2,
// Cells grow with the text scale so large text stays inside the card.
childAspectRatio: 0.8 / MediaQuery.textScalerOf(context).scale(1),
crossAxisSpacing: 16,
mainAxisSpacing: 16,
),
itemCount: _courses.length,
itemBuilder: (context, i) {
final c = _courses[i];
return Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.primaries[i % Colors.primaries.length]
.withValues(alpha: 0.3),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
),
),
),
),
Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
c['title'] as String,
style: Theme.of(context).textTheme.titleSmall,
),
Text(
c['instructor'] as String,
style: Theme.of(context).textTheme.bodySmall,
),
Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.star, size: 14, color: Colors.amber[700]),
Text(' ${c['rating']}'),
],
),
Text('${c['hours']} hrs'),
],
),
],
),
),
],
),
);
},
),
);
}
}
Add it to your project
Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.
First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.
How it works
Four _courses appear in a GridView.builder with two columns, or three above 600px, and childAspectRatio divides by the text scale so cells grow with large fonts. Each card stacks a tinted Expanded block as a thumbnail over the title, instructor and a footer Wrap that spreads rating and hours apart. Search, filtering and tap handling are all absent, and the data is const maps.
Adapting it
- Replace the tinted
Containerwith course artwork. - Set
maxLinesandoverflowon the titleText, as long names will eat into the thumbnail. - Wrap the
Cardin anInkWellfor navigation to a course page.