Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Credits, Notes, and Reference

## Previous Version of the App

+ https://github.com/data-creative/NextTrainCT

## Flutter Installation on Mac

+ https://appdividend.com/2018/12/10/how-to-install-flutter-on-mac/
+ https://flutter.dev/
+ https://flutter.dev/docs/get-started/install/macos
+ https://flutter.dev/docs/get-started/install/macos#update-your-path
+ https://flutter.dev/docs/get-started/editor?tab=vscode
+ restart VS code, then run "Flutter: Run Flutter Doctor" in the VS Code command pallete, or `flutter doctor` in the terminal. both should work. resolve any issues raised by the doctor.
+ optionally run `flutter config --no-analytics`

### Android Studio Configuration

+ https://flutter.dev/docs/get-started/install/macos#install-android-studio
+ in Android Studio: Configure > Plugins, install the "flutter" plugin by flutter.io, and restart the application

#### Acceleration

+ https://developer.android.com/studio/run/emulator-acceleration
+ "When you create an Android Virtual Device (AVD) in the AVD Manager, you can specify whether the emulator should use hardware or software to emulate the GPU of the AVD. Hardware acceleration is recommended and is typically faster. However, you might need to use software acceleration if your computer uses graphics drivers that aren't compatible with the emulator."
+ "SDK Tools: Latest release recommended (version 17 minimum)"
+ "SDK Platform: Latest release recommended (Android 4.0.3, Revision 3, minimum)"
+ https://developer.android.com/studio/run/emulator-commandline#starting
+ `emulator -list-avds`

### Emulator / Virtual Device

+ "need an Android device running Android 4.1 (API level 16) or higher."
+ https://flutter.dev/docs/get-started/install/macos#set-up-the-android-emulator
+ create a new device

### New App

+ vs code command pallette: "Flutter: New Project". this invokes `flutter create --ios-language objc --android-language java .`
+ "In order to run your application, type: `flutter run`"
+ "Your application code is in ./lib/main.dart."

### Running the App

+ from Android Studio > AVD Manager, run the emulator
+ https://flutter.dev/docs/get-started/test-drive?tab=vscode
+ https://dartcode.org/docs/quickly-switching-between-flutter-devices/
+ vs code command pallette: "Flutter: Select Device" to verify the device is running
+ press F5 to run the app on the emulator (might need to hold "fn" key to do it)
+ ... "Launching lib/main.dart on Android SDK built for x86 in debug mode..."

### Editing the App

+ edit components in the lib/main.dart file and watch hot reload update the app in the emulator. pretty cool.

## Flutter Framework

+ `Widget`, `StatelessWidget`, `StatefulWidget` `State` come from `package:flutter/src/widgets/framework.dart`
+ `MaterialApp` and `ThemeData` comes from `package:flutter/material.dart`
+ https://youtu.be/5VbAwhBBHsg

### Material Design Components

+ https://github.com/flutter/flutter/blob/master/packages/flutter/lib/material.dart
+ https://flutter.dev/docs/development/ui/widgets/material
+ https://api.flutter.dev/flutter/material/material-library.html
+ https://api.flutter.dev/flutter/material/MaterialApp-class.html
+ https://www.youtube.com/watch?v=DL0Ix1lnC4w

### Testing Flutter Apps

+ https://flutter.dev/docs/testing
+ https://medium.com/flutter/test-flutter-apps-on-travis-3fd5142ecd8c

### Debugging Flutter Apps

+ https://flutter.dev/docs/testing/code-debugging
+ https://flutter.dev/docs/testing/code-debugging#logging
+ https://flutter.dev/docs/testing/code-debugging#setting-breakpoints
+ Hmm only see print statements when running via the terminal

## Dart Language Reference

+ https://dart.dev/guides/language
+ https://dart.dev/guides/language/language-tour
+ https://dart.dev/guides/language/effective-dart
+ [Loading code from other files](https://stackoverflow.com/a/48875430/670433)
5 changes: 5 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License

Copyright (c) 2016 - 2019 MJ Rossetti <[email protected]>.

<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# next_train_ct
# Next Train CT

Search train schedules for the Shore Line East transit agency in Connecticut, USA.

## Getting Started
## Setup

This project is a starting point for a Flutter application.
Determine whether all prerequisites have been satisfied:

A few resources to get you started if this is your first Flutter project:
```sh
flutter doctor
```

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
## Usage

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
Run locally on an emulator:

```sh
flutter run # or press "F5" in VS Code
```

## Testing

Run tests:

```sh
flutter test
```
111 changes: 111 additions & 0 deletions lib/demo.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
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
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
110 changes: 7 additions & 103 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,111 +1,15 @@
import 'package:flutter/material.dart';
import "package:flutter/material.dart";
import "routes_page.dart";

void main() => runApp(MyApp());
void main() => runApp(NextTrainApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
class NextTrainApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
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
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
title: "Next Train CT",
theme: ThemeData(primarySwatch: Colors.red),
home: RoutesPage(title: "Next Train CT"),
);
}
}
Loading