youtube_metadata 1.0.0 copy "youtube_metadata: ^1.0.0" to clipboard
youtube_metadata: ^1.0.0 copied to clipboard

A lightweight⚡ Flutter package that can fetch basic data from a youtube video url including thumbanail url

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Youtube Metadata Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      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> {
  static const String hintText = "Paste the link here....";
  static MetaDataModel metaData;

  void _fetchMetadata(String link) async {
    try {
      metaData = await YoutubeMetaData.getData(link);
    } catch (e) {
      metaData = null;
    }
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(15.0),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            TextField(
              onSubmitted: (e) => _fetchMetadata(e),
              decoration: InputDecoration(hintText: hintText),
            ),
            metaData == null
                ? Container()
                : Container(
                    child: Column(
                      children: [
                        Image.network(metaData.thumbnailUrl),
                        Divider(),
                        Text(metaData.title),
                        Divider(color: Colors.transparent),
                        Text(
                          '''channel name :  ${metaData.authorName} \n\nchannel url :${metaData.authorUrl}
                          ''',
                        ),
                      ],
                    ),
                  ),
          ],
        ),
      ),
    );
  }
}
24
likes
130
points
144
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight⚡ Flutter package that can fetch basic data from a youtube video url including thumbanail url

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, http

More

Packages that depend on youtube_metadata