Linking Patreon API with a Flutter application

180

You want something like this:

import 'package:http/http.dart' as http;
static Future<http.Response> getResponse(String endpoint)
      async {
        print ("API REQUEST $endpoint");
        http.Response response = await http.get(
            Uri.parse('$BASE_URL$endpoint'),
            headers: {
              name:val,
              name2:val
            },    
        );
        print ("API RESPONSE ${response.body}");
        if (response.statusCode != 200) {
          throw "Argh! Put error info here";
        }
        return response;
      }
Share:
180
Jared
Author by

Jared

Updated on December 01, 2022

Comments

  • Jared
    Jared over 1 year

    I am very new to using Flutter and have never properly used an API without help. I want to make my application free (without tons of ads) so I was hoping to create a Patreon to support it's upkeep. When looking for tutorial videos online or any examples of code to use for either Flutter or any other languages I know how to use, I came up empty handed. So I was posting this question here hoping that someone could help me link the Patreon API to Flutter. The documentation doesn't say it connects directly to Flutter, so you'll have to use another language to access the information (best bet is Javascript or Python on my opinion) and relay that too Flutter.

    I (and possibly other people) would need a button created for OAuth login through Patreon (that works on both iOS and Android). When the user goes through the login, it needs to grab which tier they are supporting, their username, and when their subscription will renew (monthly or yearly?). This then needs to be translated to Text widgets (displaying the tier and/or username) and a "visible:" property for Visibility widgets (displaying certain content based on the user's monthly subscription and making the same content invisible or put behind a newly visible lock page when their subscription ends/expires).

    Sorry I know this is a lot to anwser, but I'm not very experienced with APIs and Flutter. I will appreciate any anwser that helps because I really want to make my app without tons of advertisements and I'm hoping this question will help other Flutter developers with the same goal of supporting their development financial without tons of advertising effecting the user's experiences on the app.

    Patreon API OAuth Documentation https://docs.patreon.com/#oauth

    Flutter JS (I think this may help connect with the Patreon API, but I'm not sure?) https://pub.dev/packages/flutter_js

    Examples of code and a step by step guide would be fantastic, but anything will help. Thank you again!

    • Jared
      Jared about 2 years
      If anyone starts to work on this question (as I know it might take awhile) let me know with a comment and I'll do my best to anwser questions elsewhere to up the bounty here as quickly as possible.
    • Guillaume Roux
      Guillaume Roux about 2 years
      I don't think it's needed to use Patreon's libraries, you could code the entire thing in pure Dart by using just an HTTP client to call the different endpoints. What would be really needed is wrapping the API to simplify the requests. I've done something similar to wrap Twitch API in flutter: github.com/TesteurManiak/twitch_api_flutter