add_thumbnail 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

add_thumbnail Plugin #

pub package Codemagic build status GitHub last commit Open Source Love GitHub GitHub stars GitHub forks

A new Flutter package. It is build for fetching media thumbnail associate to url. On adding urls it creates thumbnail wigdet.

Download App GitHub All Releases #

Video Url #

Youtube Link:- https://www.youtube.com/watch?v=1MAuErvBtKA

Screenshots #

Initial ScreenAdd Thumbnail dialogImage thumbnail
MediaListView widgetMediaListView with multiple childrenError on invaild link
await Thumbnail.addLink(
  context: context,
  /// callback that return thumbnail information in `MediaInfo` object
   onLinkAdded: (mediaInfo) {
      print("Thumbnail title:- ${mediaInfo.title}");
      print("Thumbnail url:- ${mediaInfo.thumbnailUrl}");
  },
);
  • Invoke method Thumbnail.addLink() to display add link dialog.
  • Add valid link in text field.
  • Click Next button.
  • On Next button clicked it it fetch meta accoicated with link.
  • If fetched data contain valid image url it will shows image thumbnail.
  • Else it will show some error text.
  • Save button will visible only if thumbnail image is fetched.
  • On Save button clicked it return MediaInfo object that contains thumbnail information like title, imageUrl etc.
  • On Cancel button clicked it will close dialog and return nothing.

MediaListView Widget #

List<MediaInfo> mediaList = [];
List<String> urlList = ["https://www.youtube.com/watch?v=uv54ec8Pg1k"];
 
 MediaListView(
   titleTextStyle: TextStyle(color:Colors.white),
   titleTextBackGroundColor: Colors.grey,
   overlayChild:Icon(Icons.save),
   urls: urlList,
   mediaList: mediaList,
    onPressed: (url) {
     print(url);
   },
 );
  • To show thumbnails list pass valid media url list.
  • If this is set to null thumbnail list will create from media list
  • If mediaList and urls both have values then thumbnail list will create using both list.

Getting Started #

1. Add library to your pubspec.yaml #


dependencies:
  add_thumbnail: ^0.0.1

2. Import library in dart file #

import 'package:add_thumbnail/add_thumbnail.dart';

3. How to use FilterList #

Create of list of MediaInfo object

  List<MediaInfo> mediaList = [];

Create List of String #

List<String> urlList = ["https://www.youtube.com/watch?v=uv54ec8Pg1k"];
   void openAddLinkDialog() async {
    // Open  thumbnail dialog to add link
    await Thumbnail.addLink(
      context: context,
      /// callback that return thumbnail information in `MediaInfo` object
       onLinkAdded: (mediaInfo) {
        if (mediaInfo != null && mediaInfo.thumbnailUrl.isNotEmpty) {
          setState(() {
            mediaList.add(mediaInfo);
          });
        }
      },
    );
  }

Create MediaList widget to show thumbnail list #

Widget getMediaList() {
    return MediaListView(
      onPressed: (url) {
        print(url);
      },
      urls: urlList,
      mediaList: mediaList,
    );
  }

Call openAddLinkDialog function on floatingActionButton pressed

  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xFFEEEEEE),
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body:(mediaList == null || mediaList.isEmpty) && (urlList == null || urlList.isEmpty)
          ? Center(
              child: Text(
                "Press add button to add thumbnail.",
                style: TextStyle(color: Colors.black54, fontSize: 16),
              ),
            )
          : getMediaList(),
      floatingActionButton: FloatingActionButton(
        onPressed: openAddLinkDialog,
        tooltip: 'Add link',
        child: Icon(Icons.add),
      ),
    );
  }

Pull Requests #

I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request.

Created & Maintained By #

Sonu Sharma (Twitter) (Youtube) (Insta) Twitter Follow

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕

[0.0.1] - 07 Mar 2020

  • Add link dialog added
  • Thumbnail list widget added

[0.0.2] - 08 Mar 2020

  • TitleText, SubtitleText, TextFieldHintText and ErrorText properties added

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Add Thumbnail',
      home: MyHomePage(title: 'Add thumbnail plugin example'),
      debugShowCheckedModeBanner: false,
    );
  }
}

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

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

class _MyHomePageState extends State<MyHomePage> {
  List<MediaInfo> mediaList = [];
  List<String> urlList = ["https://www.youtube.com/watch?v=uv54ec8Pg1k"];

  void openAddLinkDialog() async {
    // Open  thumbnail dialog to add link
    await Thumbnail.addLink(
      context: context,
      /// callback that return thumbnail information in `MediaInfo` object
       onLinkAdded: (mediaInfo) {
        if (mediaInfo != null && mediaInfo.thumbnailUrl.isNotEmpty) {
          setState(() {
            mediaList.add(mediaInfo);
          });
        }
      },
    );
  }

  Widget getMediaList() {
    return MediaListView(
      onPressed: (url) {
        print(url);
      },
      urls: urlList,
      mediaList: mediaList,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xFFEEEEEE),
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body:(mediaList == null || mediaList.isEmpty) && (urlList == null || urlList.isEmpty)
          ? Center(
              child: Text(
                "Press add button to add thumbnail.",
                style: TextStyle(color: Colors.black54, fontSize: 16),
              ),
            )
          : getMediaList(),
      floatingActionButton: FloatingActionButton(
        onPressed: openAddLinkDialog,
        tooltip: 'Add link',
        child: Icon(Icons.add),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  add_thumbnail: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:add_thumbnail/add_thumbnail.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
30
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Jul 12, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • add_thumbnail that is a package requiring null.

Health suggestions

Fix lib/src/widget/add_thumbnail_widget.dart. (-1 points)

Analysis of lib/src/widget/add_thumbnail_widget.dart reported 2 hints:

line 221 col 22: 'title' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline6. This feature was deprecated after v1.13.8..

line 229 col 22: 'subtitle' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is subtitle2. This feature was deprecated after v1.13.8..

Format lib/add_thumbnail.dart.

Run flutter format to format lib/add_thumbnail.dart.

Format lib/src/bloc/bloc.dart.

Run flutter format to format lib/src/bloc/bloc.dart.

Fix additional 7 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/bloc/thumbnail_event.dart (Run flutter format to format lib/src/bloc/thumbnail_event.dart.)
  • lib/src/bloc/thumbnail_state.dart (Run flutter format to format lib/src/bloc/thumbnail_state.dart.)
  • lib/src/model/media_info.dart (Run flutter format to format lib/src/model/media_info.dart.)
  • lib/src/resources/apiProvider.dart (Run flutter format to format lib/src/resources/apiProvider.dart.)
  • lib/src/resources/repository.dart (Run flutter format to format lib/src/resources/repository.dart.)
  • lib/src/widget/custom_card.dart (Run flutter format to format lib/src/widget/custom_card.dart.)
  • lib/thumbnail_list_vew.dart (Run flutter format to format lib/thumbnail_list_vew.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (flutter_bloc, rxdart).

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: http.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
equatable ^1.0.3 1.2.2
flutter 0.0.0
flutter_bloc ^3.2.0 3.2.0 5.0.1
http any 0.12.1
rxdart ^0.23.1 0.23.1 0.24.1
Transitive dependencies
bloc 3.0.0 5.0.1
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
meta 1.1.8 1.2.2
nested 0.0.4
path 1.7.0
pedantic 1.9.0 1.9.2
provider 4.3.1
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test