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, __) {
return MaterialButton(
minWidth: p.isSelectedNotEmpty ? 48 : 20,
height: appBarItemHeight,
padding: const EdgeInsets.symmetric(horizontal: 12),
color: theme.colorScheme.secondary,
disabledColor: theme.dividerColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3),
),
onPressed: p.isSelectedNotEmpty
? () => Navigator.of(context).maybePop(p.selectedAssets)
: null,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: ScaleText(
p.isSelectedNotEmpty && !isSingleAssetMode
? '${textDelegate.confirm}'
' (${p.selectedAssets.length}/${p.maxAssets})'
: textDelegate.confirm,
style: TextStyle(
color: p.isSelectedNotEmpty
? theme.textTheme.bodyLarge?.color
: theme.textTheme.bodySmall?.color,
fontSize: 17,
fontWeight: FontWeight.normal,
),
semanticsLabel: p.isSelectedNotEmpty && !isSingleAssetMode
? '${semanticsTextDelegate.confirm}'
' (${p.selectedAssets.length}/${p.maxAssets})'
: semanticsTextDelegate.confirm,
),
);
},
);
}