An open API service indexing awesome lists of open source software.

https://github.com/abdulawalarif/provider_from_course

This project is from a course of Vandad Nahavandipoor explained Provider for Flutter State Management solution
https://github.com/abdulawalarif/provider_from_course

android app flutter flutter-example ios mobile

Last synced: 7 months ago
JSON representation

This project is from a course of Vandad Nahavandipoor explained Provider for Flutter State Management solution

Awesome Lists containing this project

README

          

# This project is for excerising Provider with Flutter

## A Flutter project implementing three different example project with provider.

## Features

**1. This Flutter app demonstrates a breadcrumb navigation system using the Provider package to manage state. Breadcrumbs help track user navigation and indicate the current location within an app.**

- Dynamic Breadcrumb Creation
- Breadcrumb State Management

**2. This Flutter application demonstrates the use of the provider package for efficient state management, focusing on selective widget updates based on data changes.**

- Utilizes context.watch and context.select for listening to provider updates, ensuring widgets rebuild only when relevant data changes.
- Updates CheapObject every second and ExpensiveObject every 10 seconds using periodic streams.
- Provides buttons to start and stop the periodic updates of objects dynamically.
- CheapWidget, ExpensiveWidget, and ObjectProviderWidget rebuild independently based on their specific data dependencies.

**3. This Flutter project demonstrates the use of MultiProvider with StreamProvider to create a dynamic UI that updates based on time.**

- Seconds widget updates every second. And Minutes widget updates every minute.
- Uses StreamProvider to listen to and provide streams of Seconds and Minutes.



## File stracture

├── lib
│ ├── main.dart
│ ├── bread_crumb_example.dart
│ ├── cheap_and_expensive_object.dart
│ ├── multi_provider.dart

## Run Locally

Clone the project

```bash
git clone git@github.com:abdulawalarif/provider_from_course.git
```

Go to the project directory

```bash
cd provider_from_course
```

Install dependencies

```bash
flutter pub get
```

Connect a physical device or start a virtual device on your machine

```bash
flutter run
```

## How to tweak this project for your own uses

```bash
# This is type safe I won't be able to fetch ExpensiveObject on CheapObject declearations

final expensivObject = context.select(
(provider) => provider.expensiveObject,);
```

```bash
# This is looking for any changes in the whole state class then it will re-build the widgets

final objectProvider = context.watch();
```

```bash
# For manipulating list i am using consumer

Consumer(builder: (context, value, child) {

#sending the UnmodifiableListView of BreadCrumb type into BreadCrumbWidget to be renderd

return BreadCrumbWidget(breadCrumbs: value.item);
}),

````
```bash
# This code is for interecting with button
context.read().reset();
context.read().add(breadCrumb);
````

## Reporting Bugs or Requesting Features?

If you found an issue or would like to submit an improvement to this project,
please submit an issue using the issues tab above. If you would like to submit a PR with a fix, reference the issue you created!

## Known Issues and Future Work

-

## Author

- [@abdulawalarif](https://github.com/abdulawalarif)

## License

The MIT License (MIT). Please view the [License](LICENSE) File for more information.