quoter 0.0.1 copy "quoter: ^0.0.1" to clipboard
quoter: ^0.0.1 copied to clipboard

A flutter pacakge that returns random quote.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Quoter Demo',
      home: QuotePage(title: 'Quoter Demo'),
    );
  }
}

class QuotePage extends StatefulWidget {
  const QuotePage({
    Key? key,
    required this.title,
    this.quoter = const Quoter(),
  }) : super(key: key);

  final String title;
  final Quoter quoter;

  @override
  State<QuotePage> createState() => _QuotePageState();
}

class _QuotePageState extends State<QuotePage> {
  Quote? _quote;

  void _generateRandomQuote() {
    setState(() {
      _quote = widget.quoter.getRandomQuote();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              _quote?.quotee ?? 'Tap the button to generate random quote.',
            ),
            Text(
              _quote?.quotation ?? "",
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _generateRandomQuote,
        tooltip: 'generate quote',
        child: const Icon(Icons.add),
      ),
    );
  }
}
2
likes
150
pub points
64%
popularity

Publisher

unverified uploader

A flutter pacakge that returns random quote.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

equatable, flutter

More

Packages that depend on quoter