diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index dde9ac4..8e87c9a 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -226,6 +226,13 @@
+
+
+
+
+
+
+
@@ -271,6 +278,7 @@
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a7add08..e50e34e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,7 +2,9 @@
-
+
+
+
@@ -25,11 +27,11 @@
-
+
-
-
+
+
@@ -42,7 +44,7 @@
-
+
@@ -50,11 +52,14 @@
-
+
-
-
+
+
+
+
+
@@ -63,7 +68,7 @@
-
+
@@ -79,7 +84,11 @@
-
+
+
+
+
+
@@ -91,11 +100,12 @@
@@ -111,9 +121,9 @@
-
+
-
+
@@ -172,7 +182,11 @@
-
+
+
+
+
+
@@ -183,11 +197,6 @@
-
-
-
-
-
@@ -200,11 +209,11 @@
+
-
@@ -222,9 +231,6 @@
-
-
-
@@ -252,6 +258,9 @@
+
+
+
@@ -263,12 +272,12 @@
-
+
-
+
@@ -276,8 +285,8 @@
-
-
+
+
@@ -318,9 +327,6 @@
-
-
-
@@ -338,7 +344,7 @@
-
+
@@ -348,24 +354,34 @@
-
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
-
+
diff --git a/eight_queens/lib/main.dart b/eight_queens/lib/main.dart
index d23f862..83642c0 100644
--- a/eight_queens/lib/main.dart
+++ b/eight_queens/lib/main.dart
@@ -2,7 +2,7 @@ import 'package:eight_queens/queens.dart';
import 'package:eight_queens/results.dart';
import 'package:flutter/material.dart';
import 'package:progress_dialog/progress_dialog.dart';
-
+import 'package:validators/validators.dart';
void main() => runApp(MyApp());
@@ -40,6 +40,7 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State {
int _boardSize = 0;
ProgressDialog pr;
+ bool shouldCheck;
// Create a controller to retrieve data from the TextField
final boardController = TextEditingController();
@@ -51,11 +52,49 @@ class _MyHomePageState extends State {
super.dispose();
}
+ void _showDialogBuilder(String title, String message) {
+ showDialog(context: context,builder: (BuildContext context){
+ return AlertDialog(
+ title: new Text(title),
+ content: new Text(message),
+ actions: [
+ new FlatButton(
+ child: new Text("close"), onPressed: () {
+ setState(() {
+ _boardSize = 0;
+ });
+ Navigator.of(context).pop();
+ })
+ ],
+ );
+ });
+ }
+
+ @override
+ void initState() {
+ // TODO: implement initState
+ setState(() {
+ shouldCheck = true;
+ });
+ super.initState();
+ }
+
/**
* Retrieve the board number and pass it to the eight queens controller
* TODO: Create the Responsible class in Dart
*/
void _startProcessing() async {
+
+ if(boardController.text.isEmpty){
+ _showDialogBuilder("Empty Textfield", "Please enter a value into the text field");
+ return;
+ }
+
+ if(boardController.text.isNotEmpty && !isNumeric(boardController.text)) {
+ _showDialogBuilder("Non numeric", "Please enter a numeric value into the text field");
+ return;
+ }
+
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
diff --git a/eight_queens/pubspec.yaml b/eight_queens/pubspec.yaml
index 216c2f7..0366a86 100644
--- a/eight_queens/pubspec.yaml
+++ b/eight_queens/pubspec.yaml
@@ -20,6 +20,7 @@ dependencies:
flutter:
sdk: flutter
shared_preferences : ^0.5.6
+ validators: ^2.0.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.