selectButton method

  1. @override
Widget selectButton(
  1. BuildContext context
)
override

Select button. 选择按钮

Implementation

@override
Widget selectButton(BuildContext context) {
  return CNP<AssetPickerViewerProvider<AssetEntity>>.value(
    value: provider!,
    builder: (_, Widget? w) => StreamBuilder<int>(
      initialData: currentIndex,
      stream: pageStreamController.stream,
      builder: (BuildContext _, AsyncSnapshot<int> s) {
        final AssetEntity asset = previewAssets.elementAt(s.data!);
        return Selector<AssetPickerViewerProvider<AssetEntity>,
            List<AssetEntity>>(
          selector: (_, AssetPickerViewerProvider<AssetEntity> p) =>
              p.currentlySelectedAssets,
          builder: (BuildContext c, List<AssetEntity> assets, _) {
            final bool isSelected = assets.contains(asset);
            return Semantics(
              selected: isSelected,
              label: semanticsTextDelegate.select,
              onTap: () => onChangingSelected(context, asset, isSelected),
              onTapHint: semanticsTextDelegate.select,
              excludeSemantics: true,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: <Widget>[
                  if (isAppleOS)
                    _appleOSSelectButton(c, isSelected, asset)
                  else
                    _androidSelectButton(c, isSelected, asset),
                  if (!isAppleOS)
                    ScaleText(
                      textDelegate.select,
                      style: const TextStyle(fontSize: 17, height: 1),
                      semanticsLabel: semanticsTextDelegate.select,
                    ),
                ],
              ),
            );
          },
        );
      },
    ),
  );
}