Skip to content

Commit be5543e

Browse files
add performDijkstra
1 parent a6a54b7 commit be5543e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/features/grid/view/grid_page.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BorderDirectional _thineVerticalBorder() => BorderDirectional(
2121
top: _borderSide(true),
2222
start: _borderSide(true),
2323
end: _borderSide(true),
24-
bottom: _borderSide(true),
24+
bottom: _borderSide(true),
2525
);
2626

2727
class GridPage extends StatelessWidget {
@@ -32,6 +32,16 @@ class GridPage extends StatelessWidget {
3232
return Scaffold(
3333
appBar: AppBar(
3434
actions: [
35+
Consumer(
36+
builder: (context, ref, _) {
37+
return TextButton(
38+
onPressed: () {
39+
ref.read(gridNotifierProvider.notifier).performDijkstra();
40+
},
41+
child: const RegularText("Start Dijkstra"),
42+
);
43+
},
44+
),
3545
Consumer(
3646
builder: (context, ref, _) {
3747
return TextButton(

lib/features/grid/view_model/grid_notifier.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class GridNotifierCubit extends StateNotifier<GridNotifierState> {
215215
// for marking the current grid as visited
216216
if (gridData[currentIndex] != GridStatus.startPoint &&
217217
gridData[currentIndex] != GridStatus.targetPoint) {
218-
gridData[currentIndex] = GridStatus.filledSearcher;
218+
gridData[currentIndex] = GridStatus.searcher;
219219
state = state.copyWith(gridData: List<GridStatus>.from(gridData));
220220
await Future.delayed(drawSearcherDuration);
221221
}
@@ -276,7 +276,7 @@ class GridNotifierCubit extends StateNotifier<GridNotifierState> {
276276
// Visualize the search process
277277
if (gridData[neighborIndex] != GridStatus.startPoint &&
278278
gridData[neighborIndex] != GridStatus.targetPoint) {
279-
gridData[neighborIndex] = GridStatus.filledSearcher;
279+
gridData[neighborIndex] = GridStatus.searcher;
280280
state = state.copyWith(gridData: List<GridStatus>.from(gridData));
281281
await Future.delayed(drawSearcherDuration);
282282
}

0 commit comments

Comments
 (0)