Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pubspec.yaml
  • Loading branch information
Aryan-Dang committed Jul 16, 2021
2 parents f7c63f0 + 9059950 commit 28fa22b
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 16 deletions.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# destinations

An app built using Flutter and Firebase

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

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

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.
70 changes: 70 additions & 0 deletions lib/destinationpage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2018 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
import 'main.dart';

class DestinationPage extends StatefulWidget {
const DestinationPage({Key? key, required this.title}) : super(key: key);
final String title;

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


//means that this class is a subclass which inherits State and is of type <RandomWords> - instead of Generic type T
class _DestinationPageState extends State<DestinationPage> {
final _suggestions = <WordPair>[];
final _biggerFont = const TextStyle(fontSize: 18.0);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
//wrapped in sub-widget Text
title: Text(widget.title),
),
body: _buildSuggestions(),
);
}

//builds ListView widget
Widget _buildSuggestions() {
return ListView.builder(
padding: const EdgeInsets.all(16.0),
itemBuilder: /*1*/ (context, i) {
if (i.isOdd) return const Divider(); /*2*/

final index = i ~/ 2; /*3*/
if (index >= _suggestions.length) {
_suggestions.addAll(generateWordPairs().take(10)); /*4*/
}
return _buildRow(_suggestions[index]);
});
}

//used to build each row (list tile)
Widget _buildRow(WordPair pair) {
return ListTile(
title: Text(
pair.asPascalCase,
style: _biggerFont,
),
trailing: Icon(Icons.add
),
onTap: () { // NEW lines from here...
setState(() {
//Creats a new instance of homepage: v bad change later
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MyHomePage(title: 'Home')),
);
});
},
);
}
}

10 changes: 9 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'destinationpage.dart';

void main() {
runApp(MyApp());
Expand Down Expand Up @@ -56,6 +57,10 @@ class _MyHomePageState extends State<MyHomePage> {
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => DestinationPage(title: 'Saved Destinations')),
);
});
}

Expand Down Expand Up @@ -93,6 +98,9 @@ class _MyHomePageState extends State<MyHomePage> {
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Click the button to see your saved destinations',
),
Text(
'You have pushed the button this many times:',
),
Expand All @@ -106,7 +114,7 @@ class _MyHomePageState extends State<MyHomePage> {
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
child: Icon(Icons.arrow_forward),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
english_words:
dependency: "direct main"
description:
name: english_words
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
fake_async:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
cloud_firestore: ^1.0.0 # new
firebase_auth: ^1.0.0 # new
provider: ^5.0.0 # new

english_words: ^4.0.0

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand All @@ -36,7 +36,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter

english_words: ^4.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

Expand Down

0 comments on commit 28fa22b

Please sign in to comment.