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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion analysis_options.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ android {
signingConfig signingConfigs.debug
}
}

flavorDimensions "production, development"
productFlavors {
production {
resValue "string", "app_name", "News App"
}
development {
resValue "string", "app_name", "dev-News App"
applicationIdSuffix ".development"
versionNameSuffix "-dev"
}
}
}

flutter {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="@string/app_name"
android:label="flutter_news_app"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
27 changes: 13 additions & 14 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
Expand All @@ -23,6 +27,8 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -33,6 +39,7 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
5B3FF722E95A2F7E61CC4A29 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
66E5B3579B8D3925846CAA9D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
Expand All @@ -41,6 +48,7 @@
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand All @@ -54,6 +62,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
E67F02A3DCFD50227C270464 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -83,7 +93,9 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
Expand Down Expand Up @@ -218,30 +230,17 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
};
5DEAE3B5ED2B6CBD3C04F985 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
"${PODS_ROOT}/../Flutter/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/flutter_stetho/flutter_stetho.framework",
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_stetho.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
4 changes: 0 additions & 4 deletions lib/config/base_url_config.dart

This file was deleted.

33 changes: 0 additions & 33 deletions lib/config/device_utils.dart

This file was deleted.

68 changes: 0 additions & 68 deletions lib/config/flavor_config.dart

This file was deleted.

12 changes: 0 additions & 12 deletions lib/feature/presentation/page/home/home_page.dart

This file was deleted.

8 changes: 8 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_news_app/src/ui/app.dart';
import 'package:flutter_stetho/flutter_stetho.dart';

void main() {
Stetho.initialize();
runApp(App());
}
14 changes: 0 additions & 14 deletions lib/main_development.dart

This file was deleted.

12 changes: 0 additions & 12 deletions lib/main_production.dart

This file was deleted.

82 changes: 82 additions & 0 deletions lib/src/api/api_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import 'package:dio/dio.dart';
import 'package:flutter_news_app/src/model/topheadlinesnews/response_top_headlinews_news.dart';

class ApiProvider {
final Dio _dio = Dio();
final String _baseUrl =
'https://newsapi.org/v2/top-headlines?country=id&apiKey=YOUR_API_KEY';

void printOutError(error, StackTrace stacktrace) {
print('Exception occured: $error with stacktrace: $stacktrace');
}

Future<ResponseTopHeadlinesNews> getTopHeadlinesNews() async {
try {
final response = await _dio.get(_baseUrl);
return ResponseTopHeadlinesNews.fromJson(response.data);
} catch (error, stacktrace) {
printOutError(error, stacktrace);
return ResponseTopHeadlinesNews.withError('$error');
}
}

Future<ResponseTopHeadlinesNews> getTopBusinessHeadlinesNews() async {
try {
final response = await _dio.get('$_baseUrl&category=business');
return ResponseTopHeadlinesNews.fromJson(response.data);
} catch (error, stacktrace) {
printOutError(error, stacktrace);
return ResponseTopHeadlinesNews.withError('$error');
}
}

Future<ResponseTopHeadlinesNews> getTopEntertainmentHeadlinesNews() async {
try {
final response = await _dio.get('$_baseUrl&category=entertainment');
return ResponseTopHeadlinesNews.fromJson(response.data);
} catch (error, stacktrace) {
printOutError(error, stacktrace);
return ResponseTopHeadlinesNews.withError('$error');
}
}

Future<ResponseTopHeadlinesNews> getTopHealthHeadlinesNews() async {
try {
final response = await _dio.get('$_baseUrl&category=health');
return ResponseTopHeadlinesNews.fromJson(response.data);
} catch (error, stacktrace) {
printOutError(error, stacktrace);
return ResponseTopHeadlinesNews.withError('$error');
}
}

Future<ResponseTopHeadlinesNews> getTopScienceHeadlinesNews() async {
try {
final response = await _dio.get('$_baseUrl&category=science');
return ResponseTopHeadlinesNews.fromJson(response.data);
} catch (error, stacktrace) {
printOutError(error, stacktrace);
return ResponseTopHeadlinesNews.withError('$error');
}
}

Future<ResponseTopHeadlinesNews> getTopSportHeadlinesNews() async {
try {
final response = await _dio.get('$_baseUrl&category=sport');
return ResponseTopHeadlinesNews.fromJson(response.data);
} catch (error, stacktrace) {
printOutError(error, stacktrace);
return ResponseTopHeadlinesNews.withError('$error');
}
}

Future<ResponseTopHeadlinesNews> getTopTechnologyHeadlinesNews() async {
try {
final response = await _dio.get('$_baseUrl&category=technology');
return ResponseTopHeadlinesNews.fromJson(response.data);
} catch (error, stacktrace) {
printOutError(error, stacktrace);
return ResponseTopHeadlinesNews.withError('$error');
}
}
}
29 changes: 29 additions & 0 deletions lib/src/api/api_repository.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'dart:async';

import 'package:flutter_news_app/src/api/api_provider.dart';
import 'package:flutter_news_app/src/model/topheadlinesnews/response_top_headlinews_news.dart';

class ApiRepository {
final _apiProvider = ApiProvider();

Future<ResponseTopHeadlinesNews> fetchTopHeadlinesNews() =>
_apiProvider.getTopHeadlinesNews();

Future<ResponseTopHeadlinesNews> fetchTopBusinessHeadlinesNews() =>
_apiProvider.getTopBusinessHeadlinesNews();

Future<ResponseTopHeadlinesNews> fetchTopEntertainmentHeadlinesNews() =>
_apiProvider.getTopEntertainmentHeadlinesNews();

Future<ResponseTopHeadlinesNews> fetchTopHealthHeadlinesNews() =>
_apiProvider.getTopHealthHeadlinesNews();

Future<ResponseTopHeadlinesNews> fetchTopScienceHeadlinesNews() =>
_apiProvider.getTopScienceHeadlinesNews();

Future<ResponseTopHeadlinesNews> fetchTopSportHeadlinesNews() =>
_apiProvider.getTopSportHeadlinesNews();

Future<ResponseTopHeadlinesNews> fetchTopTechnologyHeadlinesNews() =>
_apiProvider.getTopTechnologyHeadlinesNews();
}
Loading