confirmButton method
It'll pop with AssetPickerProvider.selectedAssets when there are any assets were chosen. 当有资源已选时,点击按钮将把已选资源通过路由返回。
Implementation
@override
Widget confirmButton(BuildContext context) {
return Consumer<DefaultAssetPickerProvider>(
builder: (_, DefaultAssetPickerProvider p, __) {
final bool isSelectedNotEmpty = p.isSelectedNotEmpty;
final bool shouldAllowConfirm =
isSelectedNotEmpty || p.previousSelectedAssets.isNotEmpty;
return MaterialButton(
minWidth: shouldAllowConfirm ? 48 : 20,
height: appBarItemHeight,
padding: const EdgeInsets.symmetric(horizontal: 12),
color: theme.colorScheme.secondary,
disabledColor: theme.splashColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3),
),
onPressed: shouldAllowConfirm
? () {
Navigator.maybeOf(context)?.maybePop(p.selectedAssets);
}
: null,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: ScaleText(
isSelectedNotEmpty && !isSingleAssetMode
? '${textDelegate.confirm}'
' (${p.selectedAssets.length}/${p.maxAssets})'
: textDelegate.confirm,
style: TextStyle(
color: shouldAllowConfirm
? theme.textTheme.bodyLarge?.color
: theme.textTheme.bodySmall?.color,
fontSize: 17,
fontWeight: FontWeight.normal,
),
semanticsLabel: isSelectedNotEmpty && !isSingleAssetMode
? '${semanticsTextDelegate.confirm}'
' (${p.selectedAssets.length}/${p.maxAssets})'
: semanticsTextDelegate.confirm,
),
);
},
);
}