InShorts Flutter API

Get access to inshorts app's private API in flutter

GitHub

🌈 Categories

  • All News, Trending, Top Stories
  • National, Business, Politics, Sports, Technology
  • Startups, Entertainment, Hatke, Education, World
  • Automobile, Science, Travel, Miscellaneous, Fashion

🔥 Usage

Add the dependency in pubspec.yaml:

dependencies:
  inshorts_flutter: ^0.0.3

Basic Fetching

import 'package:inshorts_flutter/inshorts_flutter.dart';

// Fetch news for a specific category
Data newsData = await InShorts.getNews(
  newsType: NewsType.allNews, 
  language: Language.en, // Optional: Language.hi for Hindi
  limit: 10              // Optional: default is 10
);

// Access news list
if (newsData.newsList != null) {
  for (var news in newsData.newsList!) {
    print(news.newsObj?.title);
    print(news.newsObj?.content);
  }
}

Displaying in a Widget

FutureBuilder<Data>(
  future: InShorts.getNews(newsType: NewsType.trending),
  builder: (context, snapshot) {
    if (snapshot.hasData) {
      return ListView.builder(
        itemCount: snapshot.data?.newsList?.length ?? 0,
        itemBuilder: (context, index) {
          final news = snapshot.data!.newsList![index];
          return ListTile(
            title: Text(news.newsObj?.title ?? 'No Title'),
            subtitle: Text(news.newsObj?.sourceName ?? 'Unknown Source'),
          );
        },
      );
    }
    return CircularProgressIndicator();
  },
)

🏗 Data Models

Data

  • List<News>? newsList
  • String? message

News

  • String? hashId, int? rank, NewsObj? newsObj, etc.

NewsObj

  • String? title, String? content, String? authorName
  • String? imageUrl, String? sourceName, String? sourceUrl
  • int? createdAt, List<String>? categoryNames, and more.

✍️ Authors

📜 License

This project is licensed under the MIT License.

🧰 Contribution

Feel free to raise issues and open PRs.