selectButton method
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: (_, s) {
final index = s.data!;
final assetIndex =
shouldReversePreview ? previewAssets.length - index - 1 : index;
if (assetIndex < 0) {
throw IndexError.withLength(
assetIndex,
previewAssets.length,
indexable: previewAssets,
name: 'selectButton.assetIndex',
message: 'previewReversed: $shouldReversePreview\n'
'stream.index: $index\n'
'selectedAssets.length: ${selectedAssets?.length}\n'
'previewAssets.length: ${previewAssets.length}\n'
'currentIndex: $currentIndex\n'
'maxAssets: $maxAssets',
);
}
final asset = previewAssets.elementAt(assetIndex);
return Selector<AssetPickerViewerProvider<AssetEntity>,
List<AssetEntity>>(
selector: (_, p) => p.currentlySelectedAssets,
builder: (context, 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(context))
_appleOSSelectButton(context, isSelected, asset)
else
_androidSelectButton(context, isSelected, asset),
if (!isAppleOS(context))
ScaleText(
textDelegate.select,
style: const TextStyle(fontSize: 17, height: 1.2),
semanticsLabel: semanticsTextDelegate.select,
),
],
),
);
},
);
},
),
);
}