TweetWebView for Flutter

Build Status codecov pub package

TweetWebView is a Flutter widget to easily display a Twitter tweet in a WebView widget using webview_flutter.

Example 1

Display a single tweet in a TweetWebView widget using the tweet URL.

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Tweet WebView Example 1'),
      ),
      body: TweetWebView.tweetUrl("https://twitter.com/Interior/status/463440424141459456"),
    );
  }
}

Screenshot of list of tweets

Example 2

Display a single tweet in a TweetWebView widget using the tweet ID.

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Tweet WebView Example 2'),
      ),
      body: TweetWebView.tweetID('463440424141459456'),
    );
  }
}

Screenshot of list of tweets

Example 3

Display a list of tweets in TweetWebView widgets using the tweet IDs.

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Tweet WebView Example 3'),
      ),
      body: _buildBody(),
    );
  }

  Widget _buildBody() {
    final tweets = ['1065424382292566017', '1068219397293125633', '1068551446029832192', '1065362290512293888'];

    final list = ListView.builder(
      scrollDirection: Axis.vertical,
      padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
      itemCount: tweets.length,
      itemBuilder: (context, index) {
        var tweetID = tweets[index];
        return Card(
          child: TweetWebView.tweetID(tweetID),
        );
      },
    );

    final container = Container(
        color: Colors.black26,
        child: Center(child: list)
    );

    return container;

  }
}

Screenshot of list of tweets

Contributing

All comments and pull requests are welcome.

Libraries

tweet_webview