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
import 'dart:async'; | |
import 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
class NewsApi{ | |
String url = "https://raw.githubusercontent.com/RafaelBarbosatec/tutorial_flutter_medium/master/api/news.json"; | |
Future <List> loadNews() async{ | |
// Make a HTTP GET request to the CoinMarketCap API. |
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
return new MaterialApp( | |
title: 'Flutter News', | |
theme: new ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: new NoticeList(), | |
routes: <String, WidgetBuilder> { | |
'/screen1': (BuildContext context) => new Screen1(), | |
'/screen2' : (BuildContext context) => new Screen2() | |
}, |
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
Navigator.of(context).pushNamed('/screen1'); |
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
Navigator.push( | |
context, | |
MaterialPageRoute(builder: (context) => Screen1()), | |
); |
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
Widget _getListCategory(){ | |
ListView listCategory = new ListView.builder( | |
itemCount: _categorys.length, | |
scrollDirection: Axis.horizontal, | |
itemBuilder: (context, index){ | |
return _buildCategoryItem(index); | |
} | |
); |
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
Widget _buildCategoryItem(index){ | |
return new GestureDetector( | |
onTap: (){ | |
onTabCategory(index); | |
}, | |
child: new Center( | |
child: new Container( | |
margin: new EdgeInsets.only(left: 10.0), | |
child: new Material( |
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
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar(), | |
body: new Container( | |
child: new Column( | |
children: <Widget>[ | |
_getListCategory(), | |
new Expanded( |