GithubHelp home page GithubHelp logo

goswamijay / quotes-provider Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 271 KB

A Flutter package for retrieving daily quotes.

Home Page: https://pub.dev/packages/quotes_provider

License: Other

Dart 57.28% Kotlin 1.93% Swift 10.97% Objective-C 0.61% HTML 29.22%

quotes-provider's Introduction

Quotes Provider Package

A Dart package for fetching and retrieving daily quotes from the API.

Installation

To use this package, add quotes_provider as a dependency in your pubspec.yaml file:

dependencies:
  quotes_provider: ^1.0.2

Then, run flutter pub get to fetch the package.

Usage

Import the package in your Dart file:

import 'package:quotes_provider/quotes_provider.dart';

Instantiate the DailyQuotesProvider class and use it to get daily quotes:

final dailyQuotesProvider = DailyQuotesProvider();
final dailyQuote = await dailyQuotesProvider.getDailyQuote();
String quote = dailyQuote.quote;
String author = dailyQuote.author;

The getDailyQuote method fetches a random daily quote from the API and returns it as a DailyQuote object, containing the quote text and author.

Example

Here's a simple example of how you can use this package to display a daily quote in your Dart application:

import 'package:flutter/material.dart';
import 'package:quotes_provider/quotes_provider.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String quote = '';
  String author = '';

  @override
  void initState() {
    super.initState();
    fetchQuote();
  }

  void fetchQuote() async {
    final dailyQuotesProvider = DailyQuotesProvider();
    final dailyQuote = await dailyQuotesProvider.getDailyQuote();
    setState(() {
      quote = dailyQuote.quote;
      author = dailyQuote.author;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Daily Quote App'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                quote,
                style: TextStyle(fontSize: 24),
              ),
              SizedBox(height: 10),
              Text(
                '- $author',
                style: TextStyle(fontSize: 18),
              ),
              SizedBox(height: 20),
              ElevatedButton(
                onPressed: fetchQuote,
                child: Text('Get Daily Quote'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

This example demonstrates a Flutter application that displays a daily quote and author retrieved using the quotes_provider package.

Features and Contributions

If you have any feature requests or would like to contribute to this package, please feel free to create an issue or a pull request on the GitHub repository.

quotes-provider's People

Contributors

goswamijay avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.