Edgar1102
Edgar1102

Reputation: 101

How Do I preview Links in my Flutter Project

I have a chat app I'm working on and I noticed that while sending messages, it doesnt recogise the links sent. But I want the links to be recognised and preview shown. How do I go about that please. And if there are any dependencies needed. Thank you.

I'm new to flutter so I'd like details, Thank you

Upvotes: 0

Views: 480

Answers (1)

Victor Eronmosele
Victor Eronmosele

Reputation: 7716

You can use the flutter_link_previewer package. Here is a usage example from the documentation:

import 'package:flutter_link_previewer/flutter_link_previewer.dart';

LinkPreview(
  enableAnimation: true,
  onPreviewDataFetched: (data) {
    setState(() {
      // Save preview data to the state              
    });
  },
  previewData: _previewData, // Pass the preview data from the state
  text: 'https://flyer.chat',
  width: MediaQuery.of(context).size.width,
)

Upvotes: 1

Related Questions