twitter_kit 0.0.6 copy "twitter_kit: ^0.0.6" to clipboard
twitter_kit: ^0.0.6 copied to clipboard

outdated

Project to make it easier to access the Twitter API. Referring to the Twitter kit for Android.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Twitter _twitter;
  Tweet _tweet;

  @override
  void initState() {
    super.initState();
    // TODO Your key.
    _twitter = Twitter("qiA2hBrQbSy45aLMyWNGp1Cez",
      "vs7JJf0T0mCnuRWvcPE25QnvowEjpRqquhxJ8uPjlKeJ3H1pO3");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: FutureBuilder(
            future: _twitter.initialize(),
            builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
              if (snapshot.hasData) {
                if (snapshot.data) {
                  if (_tweet == null) {
                    _requestShowTweet();
                  }
                  return Text(
                      _tweet != null ? jsonEncode(_tweet.toJson()) : "ready");
                } else {
                  return RaisedButton(
                      child: const Text('Sign In With Twitter.'),
                      onPressed: () async {
                        final twitterLoginStatus = await _twitter.login();
                        if (twitterLoginStatus) {
                          setState(() {});
                        }
                      });
                }
              } else {
                return Container();
              }
            },
          ),
        ),
      ),
    );
  }

  Future<void> _requestShowTweet() async {
    _twitter.statusesService
        .unretweet(1244886093868064769, StatusesUnretweetBody())
        .then((response) {
      if (response.isSuccessful) {
        print(response.body.toJson().toString());
//        response.body.forEach((v) {
//          print(v.toJson().toString());
//        });
      } else {
        print(response.error);
      }
    });
  }
}
2
likes
0
pub points
0%
popularity

Publisher

verified publisherkitproject.info

Project to make it easier to access the Twitter API. Referring to the Twitter kit for Android.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

chopper, flutter, json_annotation, oauth1

More

Packages that depend on twitter_kit