video_info_plus 1.0.2 copy "video_info_plus: ^1.0.2" to clipboard
video_info_plus: ^1.0.2 copied to clipboard

A Dart plugin that provides functionality to extract video IDs from YouTube URLs and retrieve thumbnail images.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:video_info_plus/video_info_plus.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: 'Video Info Plus Example',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const VideoInfoScreen(),
    );
  }
}

class VideoInfoScreen extends StatefulWidget {
  const VideoInfoScreen({super.key});

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

class _VideoInfoScreenState extends State<VideoInfoScreen> {
  final VideoInfoPlus videoInfo = VideoInfoPlus();
  final TextEditingController urlController = TextEditingController();
  String videoId = '';
  String thumbnailUrl = '';

  void _getVideoInfo() {
    String url = urlController.text;
    setState(() {
      videoId = videoInfo.getVideoIdFromUrl(url: url);
      thumbnailUrl = videoInfo.getThumbnailUrl(url: url);
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // TRY THIS: Try changing the color here to a specific color (to
        // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
        // change color while the other colors stay the same.
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: const Text('Video Info Plus Example'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: [
            TextField(
              controller: urlController,
              decoration: InputDecoration(
                labelText: 'Enter YouTube URL',
                border: OutlineInputBorder(),
              ),
            ),
            SizedBox(height: 10),
            ElevatedButton(
              onPressed: _getVideoInfo,
              child: const Text('Get Video Info'),
            ),
            SizedBox(height: 20),
            Text('Video ID: $videoId'),
            SizedBox(height: 10),
            if (thumbnailUrl.isNotEmpty) Image.network(thumbnailUrl),
          ],
        ),
      ),
    );
  }
}
1
likes
160
points
46
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

A Dart plugin that provides functionality to extract video IDs from YouTube URLs and retrieve thumbnail images.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on video_info_plus