-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
# Conflicts: # pubspec.yaml
- Loading branch information
Showing
5 changed files
with
88 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')), | ||
); | ||
}); | ||
}, | ||
); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters