@@ -135,39 +135,45 @@ class PickMethod {
135135 pickerConfig: AssetPickerConfig (
136136 maxAssets: maxAssetsCount,
137137 selectedAssets: assets,
138- specialItemPosition: SpecialItemPosition .prepend,
139- specialItemBuilder: (
140- BuildContext context,
141- AssetPathEntity ? path,
142- int length,
143- ) {
144- if (path? .isAll != true ) {
145- return null ;
146- }
147- return Semantics (
148- label: textDelegate.sActionUseCameraHint,
149- button: true ,
150- onTapHint: textDelegate.sActionUseCameraHint,
151- child: GestureDetector (
152- behavior: HitTestBehavior .opaque,
153- onTap: () async {
154- Feedback .forTap (context);
155- final AssetEntity ? result = await _pickFromCamera (context);
156- if (result != null ) {
157- handleResult (context, result);
158- }
159- },
160- child: Container (
161- padding: const EdgeInsets .all (28.0 ),
162- color: Theme .of (context).dividerColor,
163- child: const FittedBox (
164- fit: BoxFit .fill,
165- child: Icon (Icons .camera_enhance),
138+ specialItems: [
139+ SpecialItem (
140+ position: SpecialItemPosition .prepend,
141+ builder: (
142+ BuildContext context,
143+ AssetPathEntity ? path,
144+ int length,
145+ bool isPermissionLimited,
146+ ) {
147+ if (path? .isAll != true ) {
148+ return null ;
149+ }
150+ return Semantics (
151+ label: textDelegate.sActionUseCameraHint,
152+ button: true ,
153+ onTapHint: textDelegate.sActionUseCameraHint,
154+ child: GestureDetector (
155+ behavior: HitTestBehavior .opaque,
156+ onTap: () async {
157+ Feedback .forTap (context);
158+ final AssetEntity ? result =
159+ await _pickFromCamera (context);
160+ if (result != null ) {
161+ handleResult (context, result);
162+ }
163+ },
164+ child: Container (
165+ padding: const EdgeInsets .all (28.0 ),
166+ color: Theme .of (context).dividerColor,
167+ child: const FittedBox (
168+ fit: BoxFit .fill,
169+ child: Icon (Icons .camera_enhance),
170+ ),
171+ ),
166172 ),
167- ),
168- ) ,
169- );
170- } ,
173+ );
174+ } ,
175+ ),
176+ ] ,
171177 ),
172178 );
173179 },
@@ -186,50 +192,56 @@ class PickMethod {
186192 pickerConfig: AssetPickerConfig (
187193 maxAssets: maxAssetsCount,
188194 selectedAssets: assets,
189- specialItemPosition: SpecialItemPosition .prepend,
190- specialItemBuilder: (
191- BuildContext context,
192- AssetPathEntity ? path,
193- int length,
194- ) {
195- if (path? .isAll != true ) {
196- return null ;
197- }
198- return Semantics (
199- label: textDelegate.sActionUseCameraHint,
200- button: true ,
201- onTapHint: textDelegate.sActionUseCameraHint,
202- child: GestureDetector (
203- behavior: HitTestBehavior .opaque,
204- onTap: () async {
205- final AssetEntity ? result = await _pickFromCamera (context);
206- if (result == null ) {
207- return ;
208- }
209- final picker = context.findAncestorWidgetOfExactType<
210- AssetPicker <AssetEntity , AssetPathEntity >> ()! ;
211- final builder =
212- picker.builder as DefaultAssetPickerBuilderDelegate ;
213- final p = builder.provider;
214- await p.switchPath (
215- PathWrapper <AssetPathEntity >(
216- path:
217- await p.currentPath! .path.obtainForNewProperties (),
195+ specialItems: [
196+ SpecialItem (
197+ position: SpecialItemPosition .prepend,
198+ builder: (
199+ BuildContext context,
200+ AssetPathEntity ? path,
201+ int length,
202+ bool isPermissionLimited,
203+ ) {
204+ if (path? .isAll != true ) {
205+ return null ;
206+ }
207+ return Semantics (
208+ label: textDelegate.sActionUseCameraHint,
209+ button: true ,
210+ onTapHint: textDelegate.sActionUseCameraHint,
211+ child: GestureDetector (
212+ behavior: HitTestBehavior .opaque,
213+ onTap: () async {
214+ final AssetEntity ? result =
215+ await _pickFromCamera (context);
216+ if (result == null ) {
217+ return ;
218+ }
219+ final picker = context.findAncestorWidgetOfExactType<
220+ AssetPicker <AssetEntity , AssetPathEntity >> ()! ;
221+ final builder =
222+ picker.builder as DefaultAssetPickerBuilderDelegate ;
223+ final p = builder.provider;
224+ await p.switchPath (
225+ PathWrapper <AssetPathEntity >(
226+ path: await p.currentPath! .path
227+ .obtainForNewProperties (),
228+ ),
229+ );
230+ p.selectAsset (result);
231+ },
232+ child: Container (
233+ padding: const EdgeInsets .all (28.0 ),
234+ color: Theme .of (context).dividerColor,
235+ child: const FittedBox (
236+ fit: BoxFit .fill,
237+ child: Icon (Icons .camera_enhance),
238+ ),
218239 ),
219- );
220- p.selectAsset (result);
221- },
222- child: Container (
223- padding: const EdgeInsets .all (28.0 ),
224- color: Theme .of (context).dividerColor,
225- child: const FittedBox (
226- fit: BoxFit .fill,
227- child: Icon (Icons .camera_enhance),
228240 ),
229- ),
230- ) ,
231- );
232- } ,
241+ );
242+ } ,
243+ ),
244+ ] ,
233245 ),
234246 );
235247 },
@@ -295,16 +307,69 @@ class PickMethod {
295307 pickerConfig: AssetPickerConfig (
296308 maxAssets: maxAssetsCount,
297309 selectedAssets: assets,
298- specialItemPosition: SpecialItemPosition .prepend,
299- specialItemBuilder: (
300- BuildContext context,
301- AssetPathEntity ? path,
302- int length,
303- ) {
304- return const Center (
305- child: Text ('Custom Widget' , textAlign: TextAlign .center),
306- );
307- },
310+ specialItems: [
311+ SpecialItem (
312+ position: SpecialItemPosition .prepend,
313+ builder: (
314+ BuildContext context,
315+ AssetPathEntity ? path,
316+ int length,
317+ bool isPermissionLimited,
318+ ) {
319+ return const Center (
320+ child: Text ('Custom Widget' , textAlign: TextAlign .center),
321+ );
322+ },
323+ ),
324+ ],
325+ ),
326+ );
327+ },
328+ );
329+ }
330+
331+ factory PickMethod .multiSpecialItems (
332+ BuildContext context,
333+ int maxAssetsCount,
334+ ) {
335+ return PickMethod (
336+ icon: '💡' ,
337+ name: context.l10n.pickMethodMultiSpecialItemsName,
338+ description: context.l10n.pickMethodMultiSpecialItemsDescription,
339+ method: (BuildContext context, List <AssetEntity > assets) {
340+ return AssetPicker .pickAssets (
341+ context,
342+ pickerConfig: AssetPickerConfig (
343+ maxAssets: maxAssetsCount,
344+ selectedAssets: assets,
345+ specialItems: [
346+ SpecialItem (
347+ position: SpecialItemPosition .prepend,
348+ builder: (
349+ BuildContext context,
350+ AssetPathEntity ? path,
351+ int length,
352+ bool isPermissionLimited,
353+ ) {
354+ return const Center (
355+ child: Text ('Prepand Widget' , textAlign: TextAlign .center),
356+ );
357+ },
358+ ),
359+ SpecialItem (
360+ position: SpecialItemPosition .append,
361+ builder: (
362+ BuildContext context,
363+ AssetPathEntity ? path,
364+ int length,
365+ bool isPermissionLimited,
366+ ) {
367+ return const Center (
368+ child: Text ('Append Widget' , textAlign: TextAlign .center),
369+ );
370+ },
371+ ),
372+ ],
308373 ),
309374 );
310375 },
0 commit comments