Skip to content

lucavenir/riverpod_paginated_views

Repository files navigation

Riverpod Paginated Views

style: very good analysis License: MIT

🤖 Generated via Riverpod Core Brick

An example repository meant to show how to handle complex pagination cases, with business logic tests.


Usage 💯

For a clean run, remember, use:

flutter clean && flutter pub get  && dart run build_runner build -d

Wait until this process is done. It can take a minute~ish.

Supported platforms

This application currently supports android, ios.

Dev server

When you're ready to see this application in action (debug mode), you can run:

# Development
$ flutter run

...And look at this software go!

Build

Building an application can be done through flutter build, but it's recommended to set up a CI/CD tool before releasing a staging or a production-ready executable.


Internals ⚙️

A few notes about this application (feel free to customize for info, warnings and stuff).

Architecture

This project uses well-known Clean Architecture principles, with a pinch of pragmatism.

Libraries

Here's a quick recap of the libraries used in this project:

  • riverpod (with the riverpod_hooks variant), as state management / caching / DI solution
  • flutter_hooks to easily handle ephimeral state
  • riverpod_generator to supercharge riverpod
  • riverpod_lint for a set of great riverpod-related lints
  • freezed
  • equatable to help testability / ease of use
  • very_good_analysis for a set of well-known lints

Tests 🧪

To run this repo's tests, you can use:

$ flutter test --coverage --test-randomize-ordering-seed random

To view the generated coverage report you can use lcov.

# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
$ open coverage/index.html

Working with Translations 🌐

This project relies on flutter_localizations and follows the official internationalization guide for Flutter.

Adding Strings

  1. To add a new localizable string, open the app_en.arb file at lib/l10n/arb/app_en.arb.
{
    "@@locale": "en",
    "counterAppBarTitle": "Counter",
    "@counterAppBarTitle": {
        "description": "Text shown in the AppBar of the Counter Page"
    }
}
  1. Then add a new key/value and description
{
    "@@locale": "en",
    "counterAppBarTitle": "Counter",
    "@counterAppBarTitle": {
        "description": "Text shown in the AppBar of the Counter Page"
    },
    "helloWorld": "Hello World",
    "@helloWorld": {
        "description": "New Hello World Text"
    }
}
  1. Use the new string
import 'package:{{name.snakeCase()}}/l10n/l10n.dart';

@override
Widget build(BuildContext context) {
  final l10n = context.l10n;
  return Text(l10n.helloWorld);
}

Adding Supported Locales

Update the CFBundleLocalizations array in the Info.plist at ios/Runner/Info.plist to include the new locale.

    ...

    <key>CFBundleLocalizations</key>
	<array>
		<string>en</string>
		<string>es</string>
	</array>

    ...

About

How to build a potentially scrollable, potentially infinite and paginated view of items, with a twist

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published