Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added VishnuRaj(apk file)/release/app-release.apk
Binary file not shown.
18 changes: 18 additions & 0 deletions VishnuRaj(apk file)/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.newsapp",
"variantName": "processReleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "1.0.0",
"outputFile": "app-release.apk"
}
]
}
Binary file added VishnuRaj-apk/release/app-release.apk
Binary file not shown.
18 changes: 18 additions & 0 deletions VishnuRaj-apk/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.newsapp",
"variantName": "processReleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "1.0.0",
"outputFile": "app-release.apk"
}
]
}
26 changes: 26 additions & 0 deletions VishnuRaj-code/lib/api/news.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'dart:convert';

import 'package:http/http.dart' as http;
import 'package:newsapp/model/article_model.dart';
class News{

Future<List<Article>>getNews(String category)async{
String url ='https://newsapi.org/v2/top-headlines?country=in&apiKey=493cf1d1db874e6595b36b7b17acd4c9';
var response=await http.get(Uri.parse(url));
if(response.statusCode == 200){
Map<String, dynamic> _json = json.decode(response.body);
List<dynamic> body = _json['articles'];
List<Article> articles = [];
body.forEach((element) {
try {
articles.add(Article.fromJson(element));
} catch (_){}
});
return articles;
print(response.body);
}
else
throw
Exception(("Can't get the Articles"));
}
}
28 changes: 28 additions & 0 deletions VishnuRaj-code/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
import 'package:newsapp/screen/home/details/detailNews.dart';
import 'screen/home/config/themes/themes.dart';
import 'screen/home/home_page.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'NEWS APP',
theme: themes(),
routes: {
DetailNews.routeName:(ctx)=>DetailNews(),
},
home:Homepage(),
);
}


}
99 changes: 99 additions & 0 deletions VishnuRaj-code/lib/model/article_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// To parse this JSON data, do
//
// final welcome = welcomeFromJson(jsonString);

import 'dart:convert';

Welcome welcomeFromJson(String str) => Welcome.fromJson(json.decode(str));

String welcomeToJson(Welcome data) => json.encode(data.toJson());

class Welcome {
Welcome({
required this.status,
required this.totalResults,
required this.articles,
});

final String status;
final int totalResults;
final List<Article> articles;

factory Welcome.fromJson(Map<String, dynamic> json) => Welcome(
status: json["status"],
totalResults: json["totalResults"],
articles: List<Article>.from(json["articles"].map((x) => Article.fromJson(x))),
);

Map<String, dynamic> toJson() => {
"status": status,
"totalResults": totalResults,
"articles": List<dynamic>.from(articles.map((x) => x.toJson())),
};
}

class Article {
Article({

//required this.author,
required this.title,
required this.description,
required this.url,
required this.urlToImage,
//required this.publishedAt,
//required this.content,
});

//final Source source;
//final String author;
final String title;
final String description;
final String url;
final String urlToImage;
// final DateTime publishedAt;
//final String content;

factory Article.fromJson(Map<String, dynamic> json) => Article(
// source: Source.fromJson(json["source"]),
// author: json["author"] == null ? null : json["author"],
title: json["title"] as String,
description: json["description"] as String,
url: json["url"] as String,
urlToImage: json["urlToImage"] as String,
// publishedAt: DateTime.parse(json["publishedAt"]),
//content: json["content"] == null ? null : json["content"],
);



Map<String, dynamic> toJson() => {
//"source": source.toJson(),
//"author": author == null ? null : author,
"title": title,
"description": description,
"url": url,
"urlToImage": urlToImage as String?,
// "publishedAt": publishedAt.toIso8601String(),
//"content": content == null ? null : content,
};
}

// class Source {
// Source({
// required this.id,
// required this.name,
// });

// final String id;
// final String name;

// factory Source.fromJson(Map<String, dynamic> json) => Source(
// id: json["id"] == null ? null : json["id"],
// name: json["name"],
// );

// Map<String, dynamic> toJson() => {
// "id": id == null ? null : id,
// "name": name,
// };
// }
19 changes: 19 additions & 0 deletions VishnuRaj-code/lib/screen/home/config/themes/themes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';

ThemeData themes() {
return ThemeData(

primarySwatch: Colors.blue,
textTheme: TextTheme(
bodyText1: TextStyle(color: Colors.black45,

),

),
primaryTextTheme:TextTheme(
headline4: TextStyle(color:Colors.blueGrey,fontWeight:FontWeight.w600),
headline6:TextStyle(color:Colors.blueGrey),
bodyText1:TextStyle(color:Colors.blueGrey),
)
);
}
4 changes: 4 additions & 0 deletions VishnuRaj-code/lib/screen/home/config/var/var.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

final String profileImage='https://media.istockphoto.com/photos/woman-hacker-face-picture-id1147603755?b=1&k=20&m=1147603755&s=170667a&w=0&h=OlPOOjxOqBOlRCIs0tP3r1WLJ6o99anuBROeb6QihwI=';
final String cricketImage='https://images.unsplash.com/photo-1589801258579-18e091f4ca26?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8OXx8Y3JpY2tldHxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=500&q=60';
final String kanewilliamson='https://images.firstpost.com/wp-content/uploads/2021/11/Williamson-practiCE-Kanpur-640-AFP.jpg?impolicy=website&width=640&height=363';
47 changes: 47 additions & 0 deletions VishnuRaj-code/lib/screen/home/details/detailNews.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:newsapp/screen/home/widget/mainbar.dart';

class DetailNews extends StatelessWidget {
static const routeName = 'DetailName';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.share,
color: Colors.black,
),
)
],
leading: IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: Icon(
Icons.arrow_back_sharp,
color: Colors.black,
),
),
),
body: SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Main_bar(),
const SizedBox(height:8),

],
),
),
)),
);
}
}
47 changes: 47 additions & 0 deletions VishnuRaj-code/lib/screen/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'widget/categorylist.dart';
import 'widget/custom_tile.dart';
import 'widget/customappbar.dart';
import 'widget/recentnews.dart';
import 'widget/titlebar.dart';


class Homepage extends StatefulWidget {
const Homepage({Key? key}) : super(key: key);

@override
State<Homepage> createState() => _HomepageState();
}

class _HomepageState extends State<Homepage> {
String category="General";
void updateIdCategory( newCategory){
setState(() {

category=newCategory;
});
}

@override
Widget build(BuildContext context) {

return Scaffold(
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height:10),
CustomAppbar(),
SizedBox(height:10),
Category_List(onCategoryChanged: (String category){
updateIdCategory(category);
}
),
RecentNews(category:category),
],
),
),
);
}
}

32 changes: 32 additions & 0 deletions VishnuRaj-code/lib/screen/home/widget/article_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import 'dart:io';

import 'package:flutter/services.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter/material.dart';

class ArticleView extends StatefulWidget {
final String url;
const ArticleView({ Key? key,required this.url }) : super(key: key);

@override
_ArticleViewState createState() => _ArticleViewState();
}

class _ArticleViewState extends State<ArticleView> {

@override
void initState() {
if (Platform.isAndroid) WebView.platform = AndroidWebView();
super.initState();

}
@override
Widget build(BuildContext context) {
return Container(

child: WebView(initialUrl: widget.url,),

);
}
}
Loading