inshorts_flutter 0.0.4 copy "inshorts_flutter: ^0.0.4" to clipboard
inshorts_flutter: ^0.0.4 copied to clipboard

A Flutter package to fetch news from InShorts using its private API. Supports multiple categories and languages.



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.


4
likes
160
points
83
downloads

Publisher

verified publisherflutterash.xyz

Weekly Downloads

A Flutter package to fetch news from InShorts using its private API. Supports multiple categories and languages.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on inshorts_flutter