flutter_autolink_text 1.0.0+1 copy "flutter_autolink_text: ^1.0.0+1" to clipboard
flutter_autolink_text: ^1.0.0+1 copied to clipboard

Flutter Autolink Text Widget.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_autolink_text/flutter_autolink_text.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'flutter_autolink_text example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'flutter_autolink_text example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {

  GlobalKey<ScaffoldState> scaffold = new GlobalKey();

  void showSnack(String link) {
    scaffold.currentState.showSnackBar(SnackBar(content: Text('Clicked: ${link}')));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: scaffold,
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: AutolinkText(
            text: 'Your text with link www.example.com',
            textStyle: TextStyle(color: Colors.black),
            linkStyle: TextStyle(color: Colors.blue),
            onWebLinkTap: (link) => showSnack(link)
        ),
      ),// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
2
likes
30
pub points
72%
popularity

Publisher

unverified uploader

Flutter Autolink Text Widget.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_autolink_text