← Code knowledge base
Reviewed Flutter implementation · 2026-10-27

card_auto_top_up_api.dart

mobile_flutter/lib/features/cards/data/card_auto_top_up_api.dart

Immutable source snapshot based on revision de78e63ed65c. Original line numbers are retained. This is implementation evidence; check the public API catalogue before adapting it.

The mobile /api/v1/mobile routes belong to the example backend. Company credentials stay on that backend. Some sections outside the documented product scope may be omitted.

Lines 1–32

import 'package:dio/dio.dart';import 'package:flutter_riverpod/flutter_riverpod.dart';import '../../../core/api/dio_provider.dart'; final cardAutoTopUpApiProvider =    Provider((ref) => CardAutoTopUpApi(ref.watch(dioProvider))); class CardAutoTopUpApi {  const CardAutoTopUpApi(this.dio);  final Dio dio;  Future<Map<String, dynamic>> load(String cardId) async =>      _settings(await dio.get<Map<String, dynamic>>(          '/api/v1/mobile/cards/${Uri.encodeComponent(cardId)}/auto-topup'));  Future<Map<String, dynamic>> save(      String mode, Map<String, dynamic> settings) async {    if (!const {'low-balance', 'failed-tx', 'deposit'}.contains(mode)) {      throw ArgumentError.value(mode);    }    return _settings(await dio.post<Map<String, dynamic>>(        '/api/v1/mobile/cards/auto-topup/$mode',        data: settings));  }   Map<String, dynamic> _settings(Response<Map<String, dynamic>> response) {    final data = response.data;    if (data == null || data['success'] != true) {      throw StateError(data?['message']?.toString() ??          'Automatic top-up settings could not be loaded.');    }    return data;  }}
HOPPA DEVELOPER ASSISTANT

What are you building?

From a question to an implementation.

Get a step-by-step flow, example code and the docs behind it. Choose a starting point or describe your feature.

Answers use the public API guide and example app code. Check the linked reference before shipping. Explore code sources ↗

Your question and recent conversation are sent to our AI provider. Don’t include API keys, personal data or card details.