Skip to content

Instantly share code, notes, and snippets.

View agarasul's full-sized avatar

agarasul

View GitHub Profile
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
alignment: Alignment.topCenter,
child: ListView(
import 'package:flutter/material.dart';
class ListItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Row(
children: <Widget>[
Text(
"Dummy title",
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
child: ListView.builder(
itemCount: 5,
import 'package:flutter/material.dart';
class ListItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Row(
children: <Widget>[
Image.network("https://github.com/agarasul/SampleNewsApp/raw/master/empty_image.png"),
Text(
Container(
height: 80,
width: 100,
child: Image.network(
"https://github.com/agarasul/SampleNewsApp/raw/master/empty_image.png")
),
Padding(
padding: EdgeInsets.all(8),
child: Row(
children: <Widget>[
Text("Dummy title"),
Text("Dummy description")
],
),
)
class News {
String status;
String error;
int totalResults;
List<Article> articles;
News({this.status, this.articles});
News.fromJson(Map<String, dynamic> newsJson)
: status = newsJson['status'],
class Article {
Source source;
String author;
Article.fromJson(Map<String, dynamic> articleJson)
: source = Source.fromJson(articleJson['source']),
author = articleJson['author']
}
class Source {
class Article {
List<Source> source;
String author;
Article.fromJson(Map<String, dynamic> articleJson)
: source = List.from(articleJson['sources'])
.map((sourceItem) => Source.fromJson(sourceItem)),
author = articleJson['author']
}