photo_widget 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

photo_widget #

Flutter widgets.

Base on photo_manager, wraps up some UI components to quickly display the photo_manager as a usable widget, inserting it wherever you need it.

Feature #

Unlike photo, this library extracts various widget units so that any widget can be extracted and put into its own project. It can also be used to quickly create your own style of image/video picker.

Currently in the development stage, the API may change at any time.

Import #

import 'package:photo_manager/photo_manager.dart';
import 'package:photo_widget/photo_widget.dart';

Widgets #

AssetPathWidget #

Display AssetPathEntity

nametyperequieddefault valuedescription
pathAssetPathEntitytrueConcepts in photo_manager, used to describe albums
buildItemAssetWidgetBuilderfalseAssetWidget.buildWidgetBuild items in the list
rowCountintfalse4There are several items in a row, see GridView for details
thumbSizeintfalse100The size of each item thumbnail
scrollingWidgetWidgetfalseconst ScrollingPlaceholder()Since loading an image is a resource-consuming operation, you only start loading images when the scrolling stops, with a placeholder before loading the image.

AssetWidget #

Display AssetEntity

nametyperequieddefault valuedescription
assetAssetEntitytrueConcepts in photo_manager, used to describe asset
thumbSizeintfalse100The item thumb size.

PickAssetWidget #

A widget with a selection box for displaying assets is generally used in scenes where you need to select an image.

nametyperequieddefault valuedescription
assetAssetEntitytrueConcepts in photo_manager, used to describe asset
thumbSizeintfalse100
providerPickerDataProvidertrueThis is a provider for picker scenes, and internally maintains the data needed by picker
onTapFunctionfalseCallback when item is clicked, exception, there is a separate response in checkbox area
pickColorMaskBuildertypedef Widget PickColorMaskBuilder(BuildContext context, bool picked)falsePickColorMask.buildWidgetUsed to mask the image when selected or unselected
pickedCheckboxBuildertypedef Widget PickedCheckboxBuilder(BuildContext context, int checkIndex)falseWhether to build the checked flag, the default is a PickedCheckbox

PickColorMask #

Colored mask

PickedCheckbox #

A default white background, the blue selection box is selected, and the selected serial number will be selected after selection.

[0.0.3] #

Rename example directory name.

[0.0.2] #

Update description for package.

[0.0.1] #

First version.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:photo_widget/photo_widget.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      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();
}

const debugPage = true;

class _MyHomePageState extends State<MyHomePage> {
  final provider = PickerDataProvider();

  @override
  Widget build(BuildContext context) {
    if (debugPage) {
      return PhotoPickHomePage(
        provider: provider,
      );
    }
    return Scaffold(
      appBar: AppBar(
        title: Text("Simple example"),
      ),
      body: Column(
        children: <Widget>[
          RaisedButton(
            onPressed: _refreshGalleryList,
            child: Text('refresh gallery list'),
          ),
          _buildDropdownButton(),
          AnimatedBuilder(
            animation: provider.currentPathNotifier,
            builder: (_, __) => Expanded(child: _buildPath()),
          ),
        ],
      ),
    );
  }

  void _refreshGalleryList() async {
    final pathList = await PhotoManager.getAssetPathList();
    provider.resetPathList(pathList, sortBy: (a, b) {
      if (a.isAll) {
        return -1;
      }
      if (b.isAll) {
        return 1;
      }
      return 0;
    });
  }

  Widget _buildDropdownButton() {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        SelectedPathDropdownButton(
          provider: provider,
        ),
        PickSureButton(
          provider: provider,
        ),
      ],
    );
  }

  Widget _buildPath() {
    if (provider.currentPath == null) {
      return Container();
    }
    return AssetPathWidget(
      path: provider.currentPath,
      buildItem: (context, asset, size) {
        return PickAssetWidget(
          asset: asset,
          provider: provider,
          thumbSize: size,
        );
        // return AssetWidget(asset: asset);
      },
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  photo_widget: ^0.0.3

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

We analyzed this package on Jul 9, 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 does not support Flutter platform linux

Because:

  • package:photo_widget/photo_widget.dart that imports:
  • package:photo_widget/src/page/pick_home_page.dart that imports:
  • package:photo_widget/src/widget/pick/pick_asset_widget.dart that imports:
  • package:photo_widget/src/widget/asset_widget.dart that imports:
  • package:photo_manager/photo_manager.dart that declares support for platforms: android, ios, macos

Package does not support Flutter platform web

Because:

  • package:photo_widget/photo_widget.dart that imports:
  • package:photo_widget/src/page/pick_home_page.dart that imports:
  • package:photo_widget/src/widget/pick/pick_asset_widget.dart that imports:
  • package:photo_widget/src/widget/asset_widget.dart that imports:
  • package:photo_manager/photo_manager.dart that declares support for platforms: android, ios, macos

Package does not support Flutter platform windows

Because:

  • package:photo_widget/photo_widget.dart that imports:
  • package:photo_widget/src/page/pick_home_page.dart that imports:
  • package:photo_widget/src/widget/pick/pick_asset_widget.dart that imports:
  • package:photo_widget/src/widget/asset_widget.dart that imports:
  • package:photo_manager/photo_manager.dart that declares support for platforms: android, ios, macos

Package not compatible with SDK dart

Because:

  • photo_widget that is a package requiring null.

Maintenance suggestions

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.2.2 <3.0.0
flutter 0.0.0
photo_manager ^0.5.1-dev.3 0.5.3+1
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 2.1.0-nullsafety
Dev dependencies
flutter_test