flutter_wordpress_content 1.0.12 copy "flutter_wordpress_content: ^1.0.12" to clipboard
flutter_wordpress_content: ^1.0.12 copied to clipboard

outdated

Flutter widget to help parse & render WordPress raw content with support for YouTube, SoundCloud and Issuu PDF embed widgets

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_wordpress_content/external/IssuuWidget.dart';
import 'package:flutter_wordpress_content/external/JWPlayerWidget.dart';
import 'package:flutter_wordpress_content/external/SoundCloudWidget.dart';
import 'package:flutter_wordpress_content/external/YouTubeWidget.dart';
import 'package:flutter_wordpress_content/model/SimpleArticle.dart';
import 'package:flutter_wordpress_content/wp_content.dart';

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

class WordPressContentExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: WPContent(
            "raw_content",
            headingTextColor: Colors.black,
            paragraphTextColor: Colors.black,
            imageCaptionTextColor: Colors.black,
            textDirection: TextDirection.ltr,
            fontFamily: 'my_font_family',
            fontSize: 19.0,
            paragraphArabicIdentifier: 'tk-adobe-arabic',
            arabicFontFamily: 'my_arabic_font_family',
            youtubeEmbedWidget: YouTubeEmbedWidget(),
            soundcloudEmbedWidget:
                SoundCloudEmbedWidget("Audio Title", "Audio Subtitle"),
            issuuEmbedWidget: IssueEmbedWidget(),
            jwPlayerWidget: JWPlayerEmbedWidget(),
          ),
        ),
      ),
    );
  }
}

class YouTubeEmbedWidget extends YouTubeWidget {
  @override
  Widget buildWithVideoId(BuildContext context, String videoId) {
    return Container(
      padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 20.0),
      child: AspectRatio(
        aspectRatio: 16 / 9,
        child: Container(
          child: Text(videoId),
        ),
      ),
    );
  }
}

class SoundCloudEmbedWidget extends SoundCloudWidget {
  final String title;
  final String subtitle;

  SoundCloudEmbedWidget(this.title, this.subtitle);

  @override
  Widget buildWithTrackId(BuildContext context, String trackId) {
    return Container(
      padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 30.0),
      child: Container(
        child: Column(
          children: <Widget>[Text(title), Text(subtitle), Text(trackId)],
        ),
      ),
    );
  }
}

class IssueEmbedWidget extends IssuuWidget {
  @override
  Widget buildWithPDF(BuildContext context, SimpleArticle pdf) {
    return Container(
      padding: EdgeInsets.all(10.0),
      child: Center(
        child: RaisedButton(
            padding: EdgeInsets.all(10.0),
            color: Colors.green,
            child: Container(
              padding: EdgeInsets.only(top: 5.0),
              child: Text(
                "View PDF",
                style: Theme.of(context)
                    .textTheme
                    .body1
                    .copyWith(color: Colors.white),
              ),
            ),
            onPressed: () {
              Navigator.push(context, MaterialPageRoute<void>(
                builder: (context) {
                  return Container(
                    child: Text(pdf.paragraphRawContent),
                  );
                },
              ));
            }),
      ),
    );
  }
}

class JWPlayerEmbedWidget extends JWPlayerWidget {
  @override
  Widget buildWithMediaId(BuildContext context, String mediaId) {
    return Container(
      padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 20.0),
      child: AspectRatio(
        aspectRatio: 16 / 9,
        child: Container(
          child: Text(mediaId),
        ),
      ),
    );
  }
}
10
likes
0
pub points
63%
popularity

Publisher

verified publishermta.tv

Flutter widget to help parse & render WordPress raw content with support for YouTube, SoundCloud and Issuu PDF embed widgets

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cached_network_image, flutter, html, html_unescape, url_launcher

More

Packages that depend on flutter_wordpress_content