This file contains hidden or 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
| //called when the button is pressed to go to the next view | |
| void _pushSaved() { | |
| Navigator.of(context).push( //get the current navigator | |
| new MaterialPageRoute<void>( //A modal route that replaces the entire screen with a platform-adaptive transition. | |
| builder: (BuildContext context) { | |
| final Iterable<ListTile> tiles = _saved.map( //iterate through our saved cryptocurrencies sequentially | |
| (crypto) { | |
| return new ListTile( //same list tile as what we have shown in the previous page | |
| leading: _getLeadingWidget(crypto['name'], Colors.blue), | |
| title: Text(crypto['name']), |
This file contains hidden or 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
| _getMainBody() { | |
| if (_loading) { | |
| return new Center( | |
| child: new CircularProgressIndicator(), | |
| ); | |
| } else { | |
| return new RefreshIndicator( | |
| child: _buildCryptoList(), | |
| onRefresh: getCryptoPrices, | |
| ); |
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| import 'dart:math'; | |
| import 'dart:async'; | |
| import 'dart:convert'; | |
| import 'dart:core'; | |
| import 'package:http/http.dart' as http; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { |
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| import 'dart:math'; | |
| import 'dart:async'; | |
| import 'dart:convert'; | |
| import 'dart:core'; | |
| import 'package:http/http.dart' as http; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { |
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| import 'dart:math'; | |
| import 'dart:async'; | |
| import 'dart:convert'; | |
| import 'dart:core'; | |
| import 'package:http/http.dart' as http; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { |
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| //material app widget | |
| return MaterialApp( | |
| title: 'Crypto Price List', |
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| //runApp calls MyApp | |
| void main() => runApp(MyApp()); | |
| //Stateless Widget since this class has no state, once created will be immutable | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| //A convenience widget that wraps a number of widgets that are commonly |
This file contains hidden or 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
| async function createValidate() { | |
| const avengersMovie = new Movie({ | |
| director: 'Joss Whedon', | |
| genre: [], //NoSQL Db -> Document can be complex object unlike MySQL | |
| price: 10 | |
| }); | |
| try { | |
| await avengersMovie.save() | |
| console.log(avengersMovie); | |
| } |
This file contains hidden or 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
| //create MovieSchema | |
| const movieSchema = new mongoose.Schema({ | |
| name: { | |
| type: String, | |
| required: true, //built in validation logic | |
| minlength: 5, | |
| maxlength: 200 | |
| }, | |
| director: String, | |
| genre: { |
This file contains hidden or 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
| async function updateMovie(id) { | |
| //query first | |
| const movie = await Movie.findById(id); | |
| if (!movie) return; | |
| movie.name = 'New Movie'; //or you can do movie.set({name:'New Movie'}) | |
| movie.save(); | |
| //update first | |
| const result = await Movie.update({_id: id}, { | |
| $set: {name: 'New Movie'} |