hyperlink_text 0.0.8 copy "hyperlink_text: ^0.0.8" to clipboard
hyperlink_text: ^0.0.8 copied to clipboard

Flutter component designed to display text with clickable hyperlinks. It allows for the creation of rich text with different styles and behavior for regular text and hyperlinks

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:hyperlink_text/Rich_text/rich_element.dart';
import 'package:hyperlink_text/hyperlink_text.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'HyperLink Text demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(
        title: 'HyperLink Text demo',
      ),
    );
  }
}

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) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(15.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            HyperLinkText(
                textStyle: const TextStyle(color: Colors.black),
                hyperLinkStyle: const TextStyle(color: Colors.blue),
                richElements: [
                  RichElement.text(
                    text:
                        "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. ",
                  ),
                  RichElement.link(
                    text: 'This is hyperLink. ',
                    url: 'https://google.com',
                  ),
                  RichElement.text(
                    text:
                        "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.",
                  ),
                ]),
            SizedBox(
              height: 60,
              width: double.maxFinite,
              child: ColoredBox(
                color: Colors.blue.shade100,
              ),
            ),
            HyperLinkText(
                textStyle: const TextStyle(color: Colors.black),
                hyperLinkStyle: const TextStyle(color: Colors.blue),
                richElements: [
                  RichElement.text(
                    text:
                        "It is a long established fact that reader will be distracted by the content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. ",
                  ),
                  RichElement.link(
                    text: 'This is hyperLink. ',
                    url: 'https://google.com',
                  ),
                  RichElement.text(
                    text:
                        "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. ",
                  ),
                  RichElement.text(
                      text:
                          "The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, ",
                      style:
                          TextStyle(fontSize: 18, color: Colors.pink.shade200)),
                  RichElement.text(
                      text:
                          "as opposed to using 'Content here, content here', making it look like readable English.",
                      style:
                          TextStyle(fontSize: 14, color: Colors.green.shade600))
                ])
          ],
        ),
      ),
    );
  }
}
2
likes
150
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter component designed to display text with clickable hyperlinks. It allows for the creation of rich text with different styles and behavior for regular text and hyperlinks

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, url_launcher

More

Packages that depend on hyperlink_text