A Flutter package that provides a clean, typed integration between your Flutter app and a Laravel REST API backend: custom HTTP client, repositories, search, mutations, deletes, and custom actions.
flutter pub add laravel_rest_api_flutter




Quick installation setup.
flutter pub add laravel_rest_api_flutter
dependencies: flutter: sdk: flutter laravel_rest_api_flutter: any dio: any # or your preferred HTTP package
Instantiate your API client and a simple repository.

final repository = ItemRepository(); Future<void> fetchItems() async { final response = await repository.search( filters: [ Filter(field: 'name', type: 'contains', value: 'Test'), ], ); if (response.isSuccessful) { print(response.body); } else { print('Error: ${response.statusCode}'); } }
class ApiHttpClient implements RestApiClient { final Dio dio; ApiHttpClient({required this.dio}); @override Future<RestApiResponse> get( String url, { Map<String, String>? headers, Map<String, String>? queryParams, }) async { try { final response = await dio.get( '\${dio.options.baseUrl}\$url', options: Options(headers: headers), queryParameters: queryParams, ); return RestApiResponse( statusCode: response.statusCode, body: response.data, ); } catch (exception, stackTrace) { return handleError(exception, stackTrace); } } // post/delete implementations can follow the same pattern }
Create or update records and trigger custom actions defined in your Laravel backend.
final newItem = ItemModel(id: 3, name: 'New Item'); await repository.mutate( body: LaravelRestApiMutateBody( mutate: [ Mutation( operation: MutationOperation.create, attributes: newItem.toJson(), ), Mutation( operation: MutationOperation.update, key: 3, attributes: {'name': 'Updated Name'}, ), ], ), );
await repository.actions( data: LaravelRestApiActionsBody( fields: [ Action(name: 'expires_at', value: '2023-04-29'), ], ), );

If you enjoyed this project, consider leaving a like on our repository.
Go to the repo