Skip to content

Commit 5d50eca

Browse files
committed
project_boards: fix deserialization error
1 parent 69fda67 commit 5d50eca

File tree

3 files changed

+47
-40
lines changed

3 files changed

+47
-40
lines changed

lib/src/models/backlog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class BacklogsResponse {
77

88
factory BacklogsResponse.fromJson(Map<String, dynamic> json) => BacklogsResponse(
99
boards: List<Backlog>.from(
10-
(json['value'] as List<dynamic>).map((x) => Backlog.fromJson(x as Map<String, dynamic>)),
10+
(json['value'] as List<dynamic>? ?? []).map((x) => Backlog.fromJson(x as Map<String, dynamic>)),
1111
),
1212
);
1313

lib/src/screens/project_boards/screen_project_boards.dart

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class _ProjectBoardsScreen extends StatelessWidget {
1414
notifier: ctrl.projectBoards,
1515
builder: (boards) {
1616
final teamBoards = {
17-
for (final teamBoard in boards!.entries) teamBoard.key: teamBoard.value.boards,
17+
for (final teamBoard in boards!.entries.where((t) => t.value.boards.isNotEmpty))
18+
teamBoard.key: teamBoard.value.boards,
1819
};
1920

2021
final teamSprints = {
@@ -24,46 +25,48 @@ class _ProjectBoardsScreen extends StatelessWidget {
2425

2526
return Column(
2627
children: [
27-
SectionHeader.withIcon(
28-
text: 'Boards',
29-
icon: DevOpsIcons.board,
30-
mainAxisAlignment: MainAxisAlignment.center,
31-
marginTop: 0,
32-
),
33-
const SizedBox(
34-
height: 8,
35-
),
36-
...teamBoards.entries.map(
37-
(tb) => Column(
38-
crossAxisAlignment: CrossAxisAlignment.start,
39-
children: [
40-
Text(
41-
tb.key.name,
42-
style: context.textTheme.bodyMedium,
43-
),
44-
const SizedBox(
45-
height: 8,
46-
),
47-
...tb.value.map(
48-
(board) => NavigationButton(
49-
onTap: () => ctrl.goToBoardDetail(tb.key, board),
50-
margin: board == tb.value.first ? EdgeInsets.zero : const EdgeInsets.only(top: 8),
51-
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
52-
child: Row(
53-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
54-
children: [
55-
Expanded(child: Text(board.name)),
56-
Icon(Icons.arrow_forward_ios),
57-
],
28+
if (teamBoards.isNotEmpty) ...[
29+
SectionHeader.withIcon(
30+
text: 'Boards',
31+
icon: DevOpsIcons.board,
32+
mainAxisAlignment: MainAxisAlignment.center,
33+
marginTop: 0,
34+
),
35+
const SizedBox(
36+
height: 8,
37+
),
38+
...teamBoards.entries.map(
39+
(tb) => Column(
40+
crossAxisAlignment: CrossAxisAlignment.start,
41+
children: [
42+
Text(
43+
tb.key.name,
44+
style: context.textTheme.bodyMedium,
45+
),
46+
const SizedBox(
47+
height: 8,
48+
),
49+
...tb.value.map(
50+
(board) => NavigationButton(
51+
onTap: () => ctrl.goToBoardDetail(tb.key, board),
52+
margin: board == tb.value.first ? EdgeInsets.zero : const EdgeInsets.only(top: 8),
53+
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
54+
child: Row(
55+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
56+
children: [
57+
Expanded(child: Text(board.name)),
58+
Icon(Icons.arrow_forward_ios),
59+
],
60+
),
5861
),
5962
),
60-
),
61-
const SizedBox(
62-
height: 16,
63-
),
64-
],
63+
const SizedBox(
64+
height: 16,
65+
),
66+
],
67+
),
6568
),
66-
),
69+
],
6770
if (teamSprints.isNotEmpty) ...[
6871
SectionHeader.withIcon(
6972
text: 'Sprints',

lib/src/services/azure_api_service.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,10 +1622,14 @@ class AzureApiServiceImpl with AppLogger implements AzureApiService {
16221622
final visibleBoards = <String, List<({String backlogId, String backlogname})>>{};
16231623

16241624
for (final team in teams) {
1625-
final backlogsRes = await _get('$_basePath/$projectName/${team.id}/_apis/work/backlogs?$_apiVersion');
1625+
final backlogsRes = await _get('$_basePath/$projectName/${team.id}/_apis/work/backlogs2?$_apiVersion');
1626+
if (backlogsRes.isError) continue;
1627+
16261628
final backlogs = BacklogsResponse.fromResponse(backlogsRes);
16271629

16281630
final teamSettingsRes = await _get('$_basePath/$projectName/${team.id}/_apis/work/teamsettings?$_apiVersion');
1631+
if (teamSettingsRes.isError) continue;
1632+
16291633
final teamSettings = TeamSettingsResponse.fromResponse(teamSettingsRes);
16301634

16311635
final visibleBacklogs = backlogs.where((b) => teamSettings.backlogVisibilities[b.id] ?? false).toList();

0 commit comments

Comments
 (0)