photoloader 0.0.5+hotfix1

  • Readme
  • Changelog
  • Example
  • Installing
  • 42

photoloader #

A new flutter plugin project.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.0.1 #

  • retrieve a list of photo path from system

0.0.2 #

0.0.3 #

  • fix missing lib

0.0.4 #

  • add id, name, title in Photo

0.0.5 #

  • support new API: loadPhotosAsJsonString

0.0.5+hotfix #

  • fix missing photosAsJsonString in PhotoLoader

0.0.5+hotfix1 #

  • fix issues

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:photoloader/photo.dart';
import 'package:photoloader/photoloader.dart';
import 'package:flutter_json_widget/flutter_json_widget.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: Text('Photo Loader Demo'),
      ),
      body: HomePage(),
    ),
  ));
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: checkPermission(),
      builder: (c, s) {
        var hasPermission = s.data;
        if (hasPermission != null && hasPermission) {
          return Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                FlatButton(
                  child: Text('API: photos'),
                  onPressed: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (c) => LoadPhotosPage(),
                      ),
                    );
                  },
                ),
                FlatButton(
                  child: Text('API: photosAsJsonString'),
                  onPressed: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (c) => LoadPhotosAsJsonStringPage(),
                      ),
                    );
                  },
                )
              ],
            ),
          );
        } else {
          return Center(
            child: Text('No Permission'),
          );
        }
      },
    );
  }
}

class LoadPhotosAsJsonStringPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Load Photos As Json String'),
      ),
      body: FutureBuilder(
        future: PhotoLoader.photosAsJsonString,
        initialData: "",
        builder: (c, s) {
          if (s.data == null) {
            return Center(child: Text('no json string returned from plugin'));
          } else if (s.data == "") {
            return CircularProgressIndicator(
              semanticsLabel: "Loading",
            );
          }
          List photoMapList = jsonDecode(s.data);
          return ListView.builder(
            itemCount: photoMapList.length,
            itemBuilder: (c, i) => ListTile(
              title: Text(photoMapList[i]['_id'].toString()),
              subtitle: JsonViewerWidget(
                photoMapList[i],
              ),
            ),
          );
        },
      ),
    );
  }
}

class LoadPhotosPage extends StatelessWidget {
  const LoadPhotosPage({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Load Photos'),
      ),
      body: photoList(),
    );
  }
}

Widget photoList() {
  return FutureBuilder(
    future: PhotoLoader.photos,
    initialData: List(),
    builder: (context, snapshot) {
      List<Photo> photos = snapshot.data;
      if (photos == null || photos.isEmpty) {
        return Center(
          child: Text('No Photos'),
        );
      } else {
        return ListView.builder(
          itemBuilder: (c, i) {
            return ListTile(
              title: Text(photos[i].name),
              subtitle: Text(photos[i].path),
            );
          },
          itemCount: photos.length,
        );
      }
    },
  );
}

Future<bool> checkPermission() async {
  var isGranted = await Permission.storage.isGranted;

  if (!isGranted) {
    var status = await Permission.storage.request();
    if (status == PermissionStatus.granted) {
      return Future.value(true);
    } else {
      return Future.value(false);
    }
  }

  return Future.value(true);
}

Use this package as a library

1. Depend on it

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


dependencies:
  photoloader: ^0.0.5+hotfix1

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:photoloader/photoloader.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
9
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
40
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform ios

Because of import path [package:photoloader/photoloader.dart] that declares support for platforms: android

Package does not support Flutter platform linux

Because of import path [package:photoloader/photoloader.dart] that declares support for platforms: android

Package does not support Flutter platform macos

Because of import path [package:photoloader/photoloader.dart] that declares support for platforms: android

Package does not support Flutter platform web

Because of import path [package:photoloader/photoloader.dart] that declares support for platforms: android

Package does not support Flutter platform windows

Because of import path [package:photoloader/photoloader.dart] that declares support for platforms: android

Package not compatible with SDK dart

because of import path [photoloader] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

14 out of 14 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/leagmain/photoloader-flutter-plugin was unreachable.

Repository URL doesn't exist. (-10 points)

At the time of the analysis the repository field https://github.com/leagmain/photoloader-flutter-plugin was unreachable.

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.7.0 <3.0.0
flutter 0.0.0
flutter_json_widget ^1.0.1 1.0.2
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test