Skip to content

Aravindpr11/News_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

News App

A small Flutter news reader (machine-test) that fetches top headlines from NewsAPI and demonstrates:

  • News feed with title, description, image, and published date
  • Search bar to filter headlines (server-side q parameter)
  • Pull-to-refresh
  • Infinite scrolling (pagination)
  • Article detail screen with Hero image transition and fade navigation
  • State management using BLoC (flutter_bloc)

Quick status

  • Analyzer: no issues (run flutter analyze locally to confirm)
  • Unit tests: test/news_bloc_test.dart covers basic bloc behavior and passes in CI when run alone

Key files

  • lib/main.dart — app entry; provides NewsBloc and starts the app
  • lib/services/news_api.dart — HTTP client for NewsAPI (contains the provided API key)
  • lib/bloc/news_bloc.dart, news_event.dart, news_state.dart
  • lib/models/article.dart, news_response.dart
  • lib/screens/news_feed.dart — feed UI, search, pull-to-refresh, infinite scroll, footer
  • lib/screens/article_detail.dart — detail UI with Hero animation
  • test/news_bloc_test.dart — unit tests for NewsBloc (uses a small Fake NewsApi)

API key

The API key provided for the test is embedded in lib/services/news_api.dart as a field:

final String apiKey = '3c908d66c17e479980705eaf3ffff95a';

This is acceptable for a short machine test, but for production or public repos move the key out of source (environment variables, CI secrets, or a runtime config file).

Run the app (Windows PowerShell)

cd D:\Projects\news_app
flutter clean
flutter pub get
flutter run

Run the bloc unit tests only

(There is an unrelated default test/widget_test.dart that may fail; run specific tests to avoid it.)

cd D:\Projects\news_app
flutter test test/news_bloc_test.dart

Run analyzer

cd D:\Projects\news_app
flutter analyze

Manual checks before submission

  1. Launch the app and verify: search, pull-to-refresh, infinite scroll (scroll to bottom repeatedly), and that articles open in the detail screen with the Hero animation.
  2. Confirm pagination loads more pages until the API's totalResults is reached and the footer shows "No more articles".
  3. Trigger a network error (turn off network) and confirm retry UI appears in the footer.

Recommended small improvements (optional)

  • Move API key into a non-checked-in config (env var or secret).
  • Remove the unused lib/providers/news_provider.dart if you want the repo cleaned (it is unused after migration to BLoC).
  • Add more tests (widget tests for NewsFeedScreen and ArticleDetailScreen) and CI steps.
  • Add UI polish (image aspect ratios, placeholder images, nicer error states).

Submission

  • Zip the project folder or push to your repository.
  • Include a short note (1-2 lines) explaining any known limitations (API daily quota, embedded API key for the test) when you submit.

If you want, I can:

  • Remove the default test/widget_test.dart to make flutter test run cleanly for the whole suite; or
  • Move the API key to a .env-style config and update the code to read from it.

Good luck with the submission — tell me which optional improvement you want me to apply and I'll do it now.

About

News App is a lightweight Flutter app that fetches top headlines from NewsAPI. It offers a searchable, pull-to-refresh feed with infinite scrolling, image-rich article tiles, and a detail view with Hero animation and smooth transitions. Built with BLoC for predictable state and easy maintenance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors