Skip to content

Instantly share code, notes, and snippets.

View Zambrella's full-sized avatar

Doug Todd Zambrella

View GitHub Profile
@Zambrella
Zambrella / empty_main.dart
Created September 22, 2019 09:26
Starting point for MMR Calculator
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'MMR Calculator',
home: null,
@Zambrella
Zambrella / blank_pubspec.yaml
Created September 22, 2019 09:29
Blank pubspec.yaml file
name: flutter_app
description: Flutter app to calculator your MMR percentile
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
@Zambrella
Zambrella / appbar_main.dart
Last active September 22, 2019 09:47
After adding the app bar to the app
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// I'm building a material app so using the MaterialApp widget gives us access to all of Flutter's material widgets
return MaterialApp(
// Implements the basic material design visual layout structure
@Zambrella
Zambrella / nonfunctional_inputpage.dart
Created September 22, 2019 14:57
Body of the input page which is non functional at the moment
class InputPage extends StatefulWidget {
@override
_InputPageState createState() => _InputPageState();
}
class _InputPageState extends State<InputPage> {
// Initialise isError bool variable to false. Used to change style of TextField widget if the user enters a value which isn't allowed.
bool _isError = false;
@override
@Zambrella
Zambrella / constants.dart
Created September 22, 2019 15:37
File for keeping all the variables that will stay the same once the app is built
import 'package:flutter/material.dart';
const double kVerticalMargin = 16;
const double kHorizontalMargin = 22;
const double kSizedBoxHeight = 20;
const TextStyle kButtonTextStyle = TextStyle(
fontSize: 16,
);
const TextStyle kPrimaryTextStyle = TextStyle(
fontSize: 32,
@Zambrella
Zambrella / resultspage.dart
Created September 22, 2019 15:38
Basically styled results page with no functionality
class ResultsPage extends StatefulWidget {
@override
_ResultsPageState createState() => _ResultsPageState();
}
class _ResultsPageState extends State<ResultsPage> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(
@Zambrella
Zambrella / constants.dart
Created September 22, 2019 17:13
constants file
import 'package:flutter/material.dart';
const double kVerticalMargin = 16;
const double kHorizontalMargin = 22;
const double kSizedBoxHeight = 20;
const TextStyle kButtonTextStyle = TextStyle(
fontSize: 16,
color: Color(0xffFEFEFE),
);
const TextStyle kAppBarTextStyle = TextStyle(
@Zambrella
Zambrella / main.dart
Created September 22, 2019 17:13
After styling the app
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'constants.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// I'm building a material app so using the MaterialApp widget gives us access to all of Flutter's material widgets
@Zambrella
Zambrella / brain1.dart
Last active September 22, 2019 20:46
Getting the response from an API call
import 'constants.dart';
import 'package:http/http.dart' as http;
const String kURL = 'https://api.opendota.com/api/distributions/';
class Brain {
Future<dynamic> getCumulativeCount() async {
http.Response response = await http.get('$kURL?apikey=$kAPIKey');
print(response.body);
}
@Zambrella
Zambrella / brain2.dart
Last active September 23, 2019 20:05
Class to get the user bucket and total number of people
import 'constants.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
class Brain {
Future<dynamic> getCumulativeCount({int userMMR}) async {
http.Response response = await http.get('$kURL?apikey=$kAPIKey');
if (response.statusCode == 200) {
String responseData = response.body;
int mmrResponse =