Skip to content

Instantly share code, notes, and snippets.

View Zambrella's full-sized avatar

Doug Todd Zambrella

View GitHub Profile
@Zambrella
Zambrella / brain3.dart
Created September 23, 2019 20:15
Added the rounding
import 'constants.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
class Brain {
Future<dynamic> getCumulativeCount({String userMMR}) async {
int roundedMMR1 = int.parse(userMMR);
int roundedMMR2 = (roundedMMR1 / 100).round();
print(roundedMMR2);
@Zambrella
Zambrella / user_input.dart
Last active September 27, 2019 19:08
Adding onChanged property to TextField
// Button press which will take people to the results page
TextField(
// User will only be inputting numbers so we want to make this easier for the user
keyboardType: TextInputType.number,
// No ones MMR is more than 4 digits long
maxLength: 4,
maxLengthEnforced: true,
style: TextStyle(
@Zambrella
Zambrella / using_brain.dart
Created September 27, 2019 19:06
Function to use the brain to get the percentage
// Function to use the brain to get the percentage
class _ResultsPageState extends State<ResultsPage> {
// Text variable to be used to show the user their Percentage
String userPercentage = '?';
void getUserPercentage () async {
// Store the result of the getCumulativeCount method found in the Brain class. This method
// requires an input which we get from the value that was passed from the input_page. To
@Zambrella
Zambrella / flavour_test.dart
Created September 29, 2019 10:55
Code responsible for deciding what text will be shown
// Creating an empty variable
String response;
// Logic deciding what text to show the user
if (double.parse(userPercentage) >= 75.0) {
response = 'You are really bad, consider uninstalling';
} else if (double.parse(userPercentage) >= 50.0 &&
double.parse(userPercentage) < 75.0) {
response = 'You\'ll be good... some day...';
} else if (double.parse(userPercentage) >= 5.0 &&
@Zambrella
Zambrella / spinner.dart
Created September 29, 2019 11:46
Function to return a spinner widget or text depending of the page is still loading
// Function to return either a spinner or some text depending on whether a result is available
Widget loadingSpinner() {
if (loading == true) {
return SpinKitDoubleBounce(
color: Colors.red,
size: 50,
);
} else {
return Text(
'$userPercentage%',
@Zambrella
Zambrella / main.dart
Created October 22, 2019 21:42
For Jesal
void main() {
Sample newSample = Sample();
print(newSample.counts);
void setToZero () {
// for (var i = 0; i < newSample.counts.length; i++) {
// newSample.counts[i] = 0;
// }
@Zambrella
Zambrella / extends.dart
Created August 15, 2020 22:05
Help plz
abstract class Entry {
String name;
Entry(this.name);
void something();
}
void main() {
BM newBM = BM(amount: 3, discomfort: 5, bristolScale: 3, name: 'Cool name', submittedTime: 'Thursday');
print(newBM.amount);
print(newBM.name);
}
class EntryListModel extends ChangeNotifier {
List<Entry2> entryList = <Entry2>[];
void addNewEntry(EntryType entryType) {
entryList.add(Entry2(entryType));
notifyListeners();
}
void deleteEntry(String id) {
entryList.removeWhere((element) => element.id == id);
@Zambrella
Zambrella / sudoku.dart
Created November 24, 2020 19:41
Algorithm to solve sudoku puzzles
import 'package:flutter/material.dart';
import 'package:sudoku_solver/constants/enums.dart';
import 'package:sudoku_solver/models/board_square.dart';
import 'package:sudoku_solver/models/position_model.dart';
import 'dart:async';
import 'package:flutter/foundation.dart';
class SudokuGrid extends ChangeNotifier {
List<List<BoardSquare>> userBoard;
int width;