import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'data_provider/data_provider.dart'; import 'package:photo_view/photo_view.dart'; class FullScreenImageView extends StatefulWidget { const FullScreenImageView( {Key? key, required this.idx, required this.items, required this.provider}) : super(key: key); final int idx; final List items; final DataProvider provider; @override State createState() => _FullScreenImageViewState(); } class _FullScreenImageViewState extends State { late final PageController _controller = PageController(initialPage: widget.idx - 1); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(widget.items[widget.idx - 1].name)), body: Center( child: CallbackShortcuts( bindings: { const SingleActivator(LogicalKeyboardKey.arrowRight): () => _controller.nextPage( duration: const Duration(milliseconds: 400), curve: Curves.ease), const SingleActivator(LogicalKeyboardKey.arrowLeft): () => _controller.previousPage( duration: const Duration(milliseconds: 400), curve: Curves.ease), }, child: Focus( autofocus: true, child: PageView.builder( itemCount: widget.items.length, controller: _controller, pageSnapping: true, itemBuilder: (context, pagePosition) { return Container( margin: const EdgeInsets.all(10), child: PhotoView( backgroundDecoration: const BoxDecoration(color: Colors.white), imageProvider: widget.provider .getImageProvider(widget.items[pagePosition].uri), ), ); }), ), ), ), ); } }