intercom_api 0.2.0 copy "intercom_api: ^0.2.0" to clipboard
intercom_api: ^0.2.0 copied to clipboard

Unofficial Intercom REST API client written in Dart

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Intercom API Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(title: 'Intercom Client Page'),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key, required this.title});

  final String title;

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  late final client = Client.accessToken('YOUR_ACCESS_TOKEN');

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FilledButton(
              onPressed: () async {
                final tags = await client.tags.list();
                debugPrint('$tags');
              },
              child: const Text('Get Tags')
            ),
            FilledButton(
              onPressed: () async {
                try {
                  final list = await client.articles.list();
                  debugPrint('$list');
                } on Error catch (e){
                  debugPrint('${e.stackTrace}');
                }
              },
              child: const Text('Get Articles')
            ),
            FilledButton(
              onPressed: () async {
                final list = await client.articles.search(phrase: 'Test');
                debugPrint('$list');
              },
              child: const Text('Search Articles')
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
140
points
19
downloads

Publisher

verified publishersummerhammer.dev

Weekly Downloads

Unofficial Intercom REST API client written in Dart

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, json_annotation

More

Packages that depend on intercom_api