overlayController property
The overlayController
is used for adding and managing the overlay
widget changes. It uses a StreamController so that the changes made
outside of the gallery can be pushed into it and shown in the UI.
See also: initialOverlay
The widgets sent through overlayController
will be wrapped inside a
StreamBuilder in the GalleryOverlay.
class _ExampleState extends State<Example> {
StreamController<Widget> overlayController =
StreamController<Widget>.broadcast();
@override
void dispose() {
overlayController.close();
super.dispose();
}
...
ElevatedButton(
onPressed: () {
SwipeImageGallery(
context: context,
children: remoteImages,
onSwipe: (index) {
overlayController.add(OverlayExample(
title: '${index + 1}/${remoteImages.length}',
));
},
overlayController: overlayController,
initialOverlay: OverlayExample(
title: '1/${remoteImages.length}',
),
).show();
},
child: Text('Open Gallery With Overlay'),
),
Implementation
final StreamController<Widget>? overlayController;