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 provider, __) {
return MaterialButton(
minWidth: provider.isSelectedNotEmpty ? 48.0 : 20.0,
height: appBarItemHeight,
padding: const EdgeInsets.symmetric(horizontal: 12.0),
color: provider.isSelectedNotEmpty ? themeColor : theme.dividerColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3.0),
),
child: Text(
provider.isSelectedNotEmpty && !isSingleAssetMode
? '${Constants.textDelegate.confirm}'
' (${provider.selectedAssets.length}/${provider.maxAssets})'
: Constants.textDelegate.confirm,
style: TextStyle(
color: provider.isSelectedNotEmpty
? theme.textTheme.bodyText1?.color
: theme.textTheme.caption?.color,
fontSize: 17.0,
fontWeight: FontWeight.normal,
),
),
onPressed: () {
if (provider.isSelectedNotEmpty) {
Navigator.of(context).pop(provider.selectedAssets);
}
},
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
);
},
);
}