flutter_link_preview 0.0.1 flutter_link_preview: ^0.0.1 copied to clipboard
This is a URL preview plugin that previews the content of a URL.
import 'package:flutter/material.dart';
import 'package:flutter_link_preview/flutter_link_preview.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
TextEditingController _controller;
@override
void initState() {
_controller = TextEditingController(text: "https://www.baidu.com");
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: TextField(
controller: _controller,
),
),
RaisedButton(
onPressed: () {
setState(() {});
},
child: const Text("get"),
),
],
),
const SizedBox(height: 15),
FlutterLinkPreview(
url: _controller.value.text,
key: ValueKey(_controller.value.text),
titleStyle: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
);
}
}