> For the complete documentation index, see [llms.txt](https://gdgaddis.gitbook.io/mobile-development-reference-tce-c01/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gdgaddis.gitbook.io/mobile-development-reference-tce-c01/products-feature/creating-products-cubit/implementing-get-products-functionality.md).

# Implementing Get Products Functionality

## Get Products

Import

```dart
import 'package:dio/dio.dart';
import 'package:techamp_flutter_shopping_app/app.dart';
```

Create an abstract class of ProductRepository

```dart
abstract class ProductRepository {
  Future<List<Product>> getAll();
}
```

Implement the abstract class

```dart
class ProductRepositoryImpl implements ProductRepository {
  final Dio _dio;

  const ProductRepositoryImpl(this._dio) : assert(_dio != null);

  @override
  Future<List<Product>> getAll() async {
    try {
      final response = await _dio.get('products');
      final List productsJson = response.data;
      return productsJson.map((json) => Product.fromJson(json)).toList();
    } on DioError catch (_) {
      throw const AppError('Network error');
    } on dynamic catch (_) {
      throw const AppError('Something went wrong.');
    }
  }
}
```
