Line data Source code
1 : import 'package:fast_immutable_collections/fast_immutable_collections.dart';
2 : import 'package:flutter/material.dart';
3 : import 'package:flutter_redux/flutter_redux.dart';
4 :
5 : import '../../../app_state.dart';
6 : import '../../models/project_model.dart';
7 : import 'projects_grid_item_new_button.dart';
8 : import 'projects_grid_item_view.dart';
9 :
10 : class ProjectsGrid extends StatelessWidget {
11 1 : const ProjectsGrid({Key? key}) : super(key: key);
12 :
13 1 : @override
14 : Widget build(BuildContext context) {
15 1 : return StoreConnector<AppState, ISet<ProjectModel>>(
16 : distinct: true,
17 4 : converter: (store) => store.state.projects.all,
18 1 : builder: (context, projects) {
19 1 : return GridView.count(
20 : shrinkWrap: true,
21 : // Create a grid with 2 columns. If you change the scrollDirection to
22 : // horizontal, this produces 2 rows.
23 : crossAxisCount: 3,
24 : // Generate 100 widgets that display their index in the List.
25 : children: projects
26 1 : .map<Widget>((project) => ProjectsGridItemView(project))
27 1 : .toList()
28 1 : ..insert(0, const ProjectsGridItemNewButton()),
29 : );
30 : });
31 : }
32 : }
|