Skip to content

Commit

Permalink
AnimatedSwitcher doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed May 3, 2024
1 parent b89a8e3 commit 557d234
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions escape_wild/lib/ui/game/craft.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,14 @@ class _CraftRecipeEntryState extends State<CraftRecipeEntry> {
itemBuilder: (ctx, i) {
return DynamicMatchingCell(
matcher: inputSlots[i],
onNotInBackpack: (item) => ItemCell(item).inCard(elevation: 0.6),
onInBackpack: (item) => ItemCell(item.meta).inCard(elevation: 5),
onNotInBackpack: (item) => ItemCell(item).inCard(
key: const ValueKey("not in backpack"),
elevation: 0.6,
),
onInBackpack: (item) => ItemCell(item.meta).inCard(
key: const ValueKey("in backpack"),
elevation: 5,
),
);
},
);
Expand Down
9 changes: 9 additions & 0 deletions escape_wild/lib/ui/game/shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,14 @@ class _DynamicMatchingCellState extends State<DynamicMatchingCell> {

@override
Widget build(BuildContext context) {
// TODO: it doesn't work
return AnimatedSwitcher(
duration: Durations.medium4,
child: buildCell(),
);
}

Widget buildCell() {
if (allMatched.isNotEmpty) {
final cur = allMatched[curIndex];
if (cur is Item) {
Expand All @@ -625,6 +633,7 @@ class _DynamicMatchingCellState extends State<DynamicMatchingCell> {
assert(false, "No item matched.");
return const NullItemCell();
}
;
}

@override
Expand Down

0 comments on commit 557d234

Please sign in to comment.