Skip to content

Commit

Permalink
Changed 'Initial State' and passed data through 'Results' params
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-headspace committed Feb 17, 2020
1 parent 8c338e1 commit 668142b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
45 changes: 26 additions & 19 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions eight_queens/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class _MyHomePageState extends State<MyHomePage> {
_boardSize = int.parse(boardController.text);
});
await pr.show();
await QueenResolver().solve(_boardSize);
int count = await QueenResolver().solve(_boardSize);
pr.dismiss();

await Navigator.push(context, MaterialPageRoute(builder: (context) => ResultsPage(title: "Results")));
await Navigator.push(context, MaterialPageRoute(builder: (context) => ResultsPage(title: "Results",count: count)));
}

@override
Expand Down
7 changes: 3 additions & 4 deletions eight_queens/lib/results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'dart:convert';

class ResultsPage extends StatefulWidget {
ResultsPage({Key key, this.title}) : super(key: key);
ResultsPage({Key key, this.title, this.count}) : super(key: key);
final String title;
final int count;

@override
_ResultsPageState createState() => _ResultsPageState();
Expand All @@ -16,10 +17,8 @@ class _ResultsPageState extends State<ResultsPage> {

Future retrieveEightQueensResults() async {
final prefs = await SharedPreferences.getInstance();
int count = await prefs.getInt("count");
print(count);
var _boards = new List();
for(int i = 1 ; i < count + 1; i++) {
for(int i = 1 ; i < widget.count + 1; i++) {
String s_board = prefs.getString('board'+i.toString());
var board = jsonDecode(s_board);
_boards.add(board);
Expand Down

0 comments on commit 668142b

Please sign in to comment.