neplox_linkpreviewer 1.0.4 copy "neplox_linkpreviewer: ^1.0.4" to clipboard
neplox_linkpreviewer: ^1.0.4 copied to clipboard

outdated

LinkPreviewer Package to show Normal URL link elements and it also provide Element object for custom UI implementation.

neplox_linkpreviewer #

The neplox_linkpreviewer package is a Flutter package that allows you to fetch metadata from a URL link and provides a link preview. It also allows users to customize the link preview and fetched metadata to implement them in their own Widgets.

Installation #

Add neplox_linkpreviewer as a dependency in your pubspec.yaml file:

dependencies:
  neplox_linkpreviewer: 1.0.4

Usage #

To fetch a link preview from a URL, you can use the NeploxLinkPreviewer widget:

class LinkPreviewer extends StatefulWidget {
  const LinkPreviewer({Key? key, required this.url});
  final String url;

  @override
  _LinkPreviewerState createState() => _LinkPreviewerState();
}

class _LinkPreviewerState extends State<LinkPreviewer> {
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(10.0),
      child: NeploxLinkPreviewer(
        url: widget.url,
        linkPreviewOptions: NLinkPreviewOptions(
          urlContentType: NURLContentType.video,
          urlLaunch: NURLLaunch.enable,
          urlLaunchIn: NURLLaunchIn.browser,
          thumbnailPreviewDirection: NThumbnailPreviewDirection.bottom,
        ),
      ),
    );
  }
}

In the above example, the NeploxLinkPreviewer widget is used to fetch and display the link preview for the specified url. You can customize the link preview options by providing a NLinkPreviewOptions object.

To fetch metadata for your own Widget, you can use the NeploxMetaDataFetcher:

class ExampleMetaFetcher extends StatefulWidget {
  const ExampleMetaFetcher({Key? key});

  @override
  _ExampleMetaFetcherState createState() => _ExampleMetaFetcherState();
}

class _ExampleMetaFetcherState extends State<ExampleMetaFetcher> {
  final NeploxMetaDataFetcher _metaDataFetcher = NeploxMetaDataFetcher.instance;

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<ElementModel>(
      future: _metaDataFetcher.fetchData(
          "https://ekantipur.com/news/2023/02/05/167556100681196555.html"),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return Text(snapshot.data?.title.toString() ?? "No Title");
        } else {
          return const Text("No data");
        }
      },
    );
  }
}

In the above example, the NeploxMetaDataFetcher is used to fetch metadata for the specified URL. The fetched data can be used to implement your own Widget. The fetchData method returns a Future that resolves to an ElementModel object containing the fetched metadata.

Documentation #

For more details and advanced usage, please refer to the API documentation.

License #

This package is released under the MIT License.

13
likes
0
points
44
downloads

Publisher

verified publishershobhit.com.np

Weekly Downloads

LinkPreviewer Package to show Normal URL link elements and it also provide Element object for custom UI implementation.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cached_network_image, flutter, html, http, shared_preferences, url_launcher

More

Packages that depend on neplox_linkpreviewer