Overview

Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.

The Ayrshare Flutter SDK package allows you to integrate Ayrshare’s social media API with your Flutter apps.

Installing

Install the package as a library in your app.

 $ flutter pub add ayrshare_flutter

Ayrshare Flutter Package

Ayrshare Flutter SDK package

Usage Example of Posting

This sample app creates a button which calls the post function. It posts a random quote and a random image to the linked Twitter and Facebook accounts. It prints the response which includes the URLs for the live posts on the social networks.

import 'package:flutter/material.dart';
import 'ayrshare_flutter.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  
  Widget build(BuildContext context) {
    return MaterialApp(
      home: PostingPage(),
    );
  }
}

class PostingPage extends StatelessWidget {
  ///TODO get your API key by signing up at ayrshare.com
  final apiKey = '###-###-###-###';

  
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: null,
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              await post(
                apiKey: apiKey,
                body: {
                  'randomPost': true,
                  'platforms': ['twitter', 'facebook'],
                  'randomMediaUrl': true
                },
              ).then((value) => print(value));
            },
            child: const Text('Post To Social'),
          ),
        ));
  }
}

More Information and Documentation