Created
December 14, 2018 01:57
Scalable and page selectable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScalableImageScreen extends StatelessWidget { | |
final List<String> imageUrls; | |
final int position; | |
ScalableImageScreen({Key key, this.imageUrls, this.position}) | |
: super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return DefaultTabController( | |
initialIndex: position, | |
length: imageUrls.length, | |
child: _PageSelector(imageUrls: imageUrls, position: position), | |
); | |
} | |
} | |
class _PageSelector extends StatelessWidget { | |
const _PageSelector({this.imageUrls, this.position}); | |
final List<String> imageUrls; | |
final int position; | |
@override | |
Widget build(BuildContext context) { | |
Widget previewWidget = Scaffold( | |
appBar: AppBar( | |
title: Text("preview"), | |
backgroundColor: Colors.black, | |
), | |
backgroundColor: Colors.black, | |
body: Column( | |
children: <Widget>[ | |
Expanded( | |
child: TabBarView( | |
children: imageUrls.map((String imageUrl) { | |
return Container( | |
child: Center( | |
child: PhotoView( | |
imageProvider: NetworkImage(imageUrl), | |
minScale: PhotoViewComputedScale.contained * 1.0, | |
maxScale: 2.0, | |
), | |
), | |
); | |
}).toList()), | |
), | |
], | |
), | |
); | |
UniqueKey key = UniqueKey(); | |
return Dismissible( | |
key: key, | |
direction: DismissDirection.vertical, | |
onDismissed: (direction) { | |
Navigator.pop(context); | |
}, | |
child: previewWidget, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment