Team Updates

//import 'dart:convert';
//import 'package:flutter/material.dart';
//import 'package:nasa/Model/Model.dart';
//import 'dart:async';
//import 'package:http/http.dart' as http;
//import 'package:url_launcher/url_launcher.dart';
//
////String API_KEY = 'National';
//Future<List<Article>> fetchArticleBySource(String source) async{
//
//
// final response =
//// await http.get('https://launchlibrary.net/1.4/agency?name==${API_KEY}');
//
// if(response.statusCode == 200) //HTTP
// {
// List articles = json.decode(response.body)['articles'];
// return articles.map((article) => new Article.fromJson(article)).toList();
// }
// else
// {
// throw Exception('Failed to load article list');
//
// }
//}
//
//class ArticleScreen extends StatefulWidget{
//
// final Source source;
//
// ArticleScreen({Key key, @required this.source}):super(key:key);
//
// @override
// State<StatefulWidget> createState() => ArticleScreenState();
//
//}
//
//class ArticleScreenState extends State<ArticleScreen>{
//
// var list_articles;
// var refreshKey = GlobalKey<RefreshIndicatorState>();
//
// @override
// void initState(){
//
// refreshListArticle();
//
// }
//
// Future<Null> refreshListArticle() async{
//
// refreshKey.currentState?.show(atTop: false);
//
// setState(() {
// list_articles = fetchArticleBySource(widget.source.id);
// });
//
// return null;
//
// }
//
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
//
// title: 'Nasa launch time',
// theme: ThemeData(primarySwatch: Colors.blue),
// home: Scaffold(
// appBar: AppBar(title: Text(widget.source.name)),
// body: Center(
//
// child: RefreshIndicator( key: refreshKey,
// child: FutureBuilder<List<Article>>(
// future: list_articles,
// builder: (context, snapshot){
// if(snapshot.hasError){
// return Text('${snapshot.error}');
// }else if(snapshot.hasData){
// List<Article> articles = snapshot.data;
// return ListView(
// children: articles.map((article) => GestureDetector(
// onTap: (){
//
// _launchUrl(article.url);
// },
// child: Card(
// elevation: 1.0,
// color: Colors.white,
// margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 8.0),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// Container(
// margin: const EdgeInsets.symmetric(vertical: 20.0, horizontal: 4.0),
// width: 100.0,
// height: 100.0,
// child: article.urlToImage != null ? Image.network(article.urlToImage): Image.asset("assets/nasa.jpg"),
//
// ),
// Expanded(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// Row(
// children: <Widget>[
// Expanded(
//
// child: Container(
// margin: const EdgeInsets.only(left: 8.0,top: 20.0,bottom: 10.0),
// child: Text(
// '${article.title}',
// style: TextStyle(
// fontSize: 16.0,
// fontWeight: FontWeight.bold
// ),
//
// ),
// ),
// )
// ],
// ),
//
// Container(
// margin: const EdgeInsets.only(left: 8.0),
// child: Text(
// '${article.description}',
// style: TextStyle(
// fontSize: 12.0,
// color: Colors.grey,
// fontWeight: FontWeight.bold
// )
//
// ),
// ),
//
//
// Container(
// margin: const EdgeInsets.only(left: 8.0, top: 10.0, bottom: 10.0),
// child: Text(
// 'Pulished At: ${article.publishedAt}',
// style: TextStyle(
// fontSize: 12.0,
// color: Colors.black12,
// fontWeight: FontWeight.bold
// )
//
// ),
// ),
//
// ],
// ),
//
// )
// ],
// ),
//
// ),
// )).toList(),
// );
// }
// return CircularProgressIndicator();
//
// },
//
// ),
// onRefresh: refreshListArticle),
//
//
// )
// ),
//
// );
//
// }
//
// _launchUrl(String url) async {
// if (await canLaunch(url)) {
// await launch(url);
// } else {
// throw ('Could not launch ${url}');
// }
// }
//
//}
//
//
//
import'dart:convert';
import'package:flutter/material.dart';
import'package:http/http.dart'as http;
import'package:nasa/Model/Model.dart';
import'dart:async';
Future<List<Source>>fetchNewsSource() async{
final response =
await http.get("https://launchlibrary.net/1.4/agency?name=National");
if(response.statusCode ==200) //HTTP
{
List sources = json.decode(response.body)['sources'];
return sources.map((source) =>newSource.fromJson(source)).toList();
}
else
{
throwException('Failed to load source list');
}
}
voidmain() =>runApp(newSourceSccreen());
classSourceSccreenextendsStatefulWidget{
@override
State<StatefulWidget>createState() =>SourceSccreenState();
}
classSourceSccreenStateextendsState<SourceSccreen>{
var list_sources;
var refreshKey =GlobalKey<RefreshIndicatorState>();
@override
voidinitState() {
super.initState();
refreshListSource();
}
@override
Widgetbuild(BuildContext context) {
returnMaterialApp(
title:'Rocket SCHDUEL',
theme:ThemeData(primarySwatch:Colors.blue),
home:Scaffold(
appBar:AppBar(title:Text('Rocket time'),),
body:Center(
child:RefreshIndicator(
key: refreshKey,
child:FutureBuilder<List<Source>>(
future: list_sources,
builder: (context, snapshot){
if(snapshot.hasError){
returnText('Error: ${snapshot.error}');
}
elseif(snapshot.hasData)
{
List<Source> sources = snapshot.data;
returnnewListView(
children: sources.map((source) =>GestureDetector(
onTap:(){
// something here
//// Navigator.push(context, MaterialPageRoute(builder: (context) => ArticleScreen(source:source)));
//
},
child:Card(
elevation:1.0,
color:Colors.white,
margin:constEdgeInsets.symmetric(vertical:8.0,horizontal:14.0),
//
child:Row(
),
//
),
//
)
//
).toList());
//
}
returnCircularProgressIndicator();
},
)
//
//
, onRefresh: refreshListSource),
),
),
);
}
Future<Null>refreshListSource() async{
refreshKey.currentState?.show(atTop:false);
setState(() {
list_sources =fetchNewsSource();
});
returnnull;
}
}
view raw main.dart hosted with ❤ by GitHub
classNasaAPI{
finalString status;
finalList<Source> sources;
NasaAPI({this.status, this.sources});
factoryNasaAPI.fromJson(Map<String, dynamic> json)
{
returnNasaAPI( status: json['status'],
sources: (json['sources'] asList).map((source) =>Source.fromJson(source)).toList());
}
}
classSource {
finalString id ;
finalString name ;
finalString countryCode ;
finalString abbrev ;
finalString type ;
finalString infoURL ;
finalString wikiURL ;
finalString infoURLs ;
finalString islsp;
finalString changed ;
Source({this.id, this.name, this.countryCode, this.abbrev, this.type, this.infoURL, this.wikiURL, this.infoURLs, this.islsp, this.changed});
factorySource.fromJson(Map<String,dynamic> json)
{
returnSource (
id: json['id'],
name: json['name'],
countryCode: json['countryCode'],
abbrev: json['abbrev'],
type: json['type'],
infoURL: json['infoURL'],
wikiURL: json['wikiURL'],
infoURLs: json['infoURLs'],
islsp: json['islsp'],
changed: json['changed'],
);
}
}
view raw model.dart hosted with ❤ by GitHub
gretor0231cheng en ho
fail to put the API library to the list
fail to put the API library to the list
gretor0231cheng en ho
change to useing launch lib API, finish the main page list
change to useing launch lib API, finish the main page list
gretor0231cheng en ho

Moblie app with launch time,but fail link to database

gretor0231cheng en ho
Opps!
Opps!
gretor0231cheng en ho
NASA Logo

SpaceApps is a NASA incubator innovation program.