Last updated:
0 purchases
repository flutter
Flutter Repository #
A package aimed at providing seamless integration between the Repository library and Flutter, creating a communication widget between them.
Installation 💻 #
❗ In order to start using Repository Builder you must have the Flutter SDK installed on your machine.
Add repository_flutter to your pubspec.yaml:
dependencies:
repository_flutter:
copied to clipboard
Install it:
flutter packages get
copied to clipboard
Usage #
Lets take a look at how to use RepositoryBuilder to provide a react to state changes in a Repository.
currencies_repository.dart #
class CurrenciesRepository extends CustomHttpRepository<Currencies> {
@override
Iterable<Currency> fromJson(json) {
return RemoteCurrenciesModel.from(
raw: jsonDecode(json),
);
}
@override
Uri get endpoint => "https://localhost:8080/api/v1/currency/supported";
}
copied to clipboard
currencies_page.dart #
class CurrenciesPage extends StatelessWidget {
const CurrenciesPage();
final _repository = CurrenciesRepository();
Widget build(BuildContext context) {
return Scaffold(
body: RepositoryBuilder(
repository: _repository,
builder: (context, currencies) {
if (currencies == null) {
return const Center(
child: SizedBox(
child: CircularProgressIndicator(),
),
);
} else {
return ListView(
children: [
for (currency in currencies)
CurrencyListTile(currency: currency)
]
);
}
}
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.