Skip to content

Commit

Permalink
fix: fixed empty builds errors
Browse files Browse the repository at this point in the history
  • Loading branch information
orteney committed Mar 2, 2024
1 parent ce41952 commit 0fdfc96
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/presentation/champion_pick/bloc/champion_pick_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ChampionPickBloc extends Bloc<ChampionPickEvent, ChampionPickState> with E
role: builds.role,
builds: builds.builds,
selectedBuildIndex: 0,
selectedPerkStyle: PerkStyle.fromId(builds.builds[0].runes.primaryPath),
selectedPerkStyle: builds.builds.isEmpty ? null : PerkStyle.fromId(builds.builds[0].runes.primaryPath),
runesImages: _getPerksImages(builds.builds),
itemImages: _getItemImages(builds.builds),
summonerSpellImages: _getSummonerSpellImages(builds.builds),
Expand All @@ -143,7 +143,7 @@ class ChampionPickBloc extends Bloc<ChampionPickEvent, ChampionPickState> with E
role: builds.role,
builds: builds.builds,
selectedBuildIndex: 0,
selectedPerkStyle: PerkStyle.fromId(builds.builds[0].runes.primaryPath),
selectedPerkStyle: builds.builds.isEmpty ? null : PerkStyle.fromId(builds.builds[0].runes.primaryPath),
runesImages: _getPerksImages(builds.builds),
itemImages: _getItemImages(builds.builds),
summonerSpellImages: _getSummonerSpellImages(builds.builds),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ActiveChampionPickState extends ChampionPickState with EquatableMixin {
final Role? role;
final List<BuildInfo> builds;
final int selectedBuildIndex;
final PerkStyle selectedPerkStyle;
final PerkStyle? selectedPerkStyle;
final Map<int, LcuImage> runesImages;
final Map<int, LcuImage> itemImages;
final Map<int, LcuImage> summonerSpellImages;
Expand Down
27 changes: 14 additions & 13 deletions lib/presentation/champion_pick/champion_pick_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class _ActiveChampionPickWidget extends StatelessWidget {
child: _BuildTab(
keyPerkIcon: state.runesImages[build.keystoneId]!,
championBuild: build,
color: index == state.selectedBuildIndex ? state.selectedPerkStyle.color : null,
color: index == state.selectedBuildIndex ? state.selectedPerkStyle?.color : null,
onTap: () =>
context.read<ChampionPickBloc>().add(TapAvailableBuildTabChampionPickEvent(index)),
),
Expand All @@ -132,18 +132,19 @@ class _ActiveChampionPickWidget extends StatelessWidget {
),
),
const SizedBox(height: 8),
LayoutBuilder(
builder: (context, constraints) {
return BuildDetails(
singleColumn: constraints.maxWidth < 720,
championBuild: state.builds[state.selectedBuildIndex],
runesImages: state.runesImages,
itemImages: state.itemImages,
summonerSpellImages: state.summonerSpellImages,
color: state.selectedPerkStyle.color,
);
},
),
if (state.builds.isNotEmpty)
LayoutBuilder(
builder: (context, constraints) {
return BuildDetails(
singleColumn: constraints.maxWidth < 720,
championBuild: state.builds[state.selectedBuildIndex],
runesImages: state.runesImages,
itemImages: state.itemImages,
summonerSpellImages: state.summonerSpellImages,
color: state.selectedPerkStyle?.color ?? Colors.transparent,
);
},
),
]
],
),
Expand Down

0 comments on commit 0fdfc96

Please sign in to comment.