flutter_social_embeds 1.0.8 copy "flutter_social_embeds: ^1.0.8" to clipboard
flutter_social_embeds: ^1.0.8 copied to clipboard

Provide a widget to easily embed social media post in flutter using web embed feature by the platform

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_social_embeds/social_embed_webview.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Social Embeds Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Social Embeds Example'),
    );
  }
}

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

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    const instagramEmbed =
        'https://www.instagram.com/p/Bn_IZ-oAtj-/?utm_source=ig_embed&ig_rid=453a13db-8b3b-4f34-8d79-2229e2c54e73';
    const xEmbed =
        '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">gonna start tweeting like I have 10 followers</p>&mdash; Opera GX (@operagxofficial) <a href="https://twitter.com/operagxofficial/status/1845867823765082224?ref_src=twsrc%5Etfw">October 14, 2024</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>';
    const tikTokEmbed =
        '<blockquote class="tiktok-embed" cite="https://www.tiktok.com/@juliariboldi/video/7426425751341255941" data-video-id="7426425751341255941" style="max-width: 605px;min-width: 325px;" > <section> <a target="_blank" title="@juliariboldi" href="https://www.tiktok.com/@juliariboldi?refer=embed">@juliariboldi</a> hacer tiktok en el aeropuerto sale muy mal @silvia.satta26 <a target="_blank" title="♬ original sound - aleja" href="https://www.tiktok.com/music/original-sound-7280963841490471723?refer=embed">♬ original sound - aleja</a> </section> </blockquote> <script async src="https://www.tiktok.com/embed.js"></script>';
    const youtubeEmbed =
        '<iframe width="560" height="315" src="https://www.youtube.com/embed/7OvsVSWB4TI?si=g23aMoeWC0Q2VVj-" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>';
    return Scaffold(
      backgroundColor: Colors.red,
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: PageView(
        children: const [
          // Instagram
          SocialEmbed(
            htmlBody: instagramEmbed,
            backgroundColor: Colors.red,
            htmlScale: 0.6,
          ),
          // X Twitter
          SocialEmbed(
            htmlBody: xEmbed,
            htmlScale: 0.7,
          ),

          // Youtube
          SocialEmbed(
            htmlBody: youtubeEmbed,
            htmlScale: 0.7,
          ),
          // TikTok
          SocialEmbed(htmlBody: tikTokEmbed),
        ],
      ),
    );
  }
}
3
likes
150
points
122
downloads
screenshot

Publisher

verified publishermassimilianomassaro.it

Weekly Downloads

Provide a widget to easily embed social media post in flutter using web embed feature by the platform

Repository (GitHub)
View/report issues

Topics

#social #webview #webview-flutter #javascript #html

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, http, localstorage, url_launcher, webview_flutter

More

Packages that depend on flutter_social_embeds