picture_display_page.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import 'package:bbyyy/my_tools/AsperctRaioImage.dart';
  2. import 'package:bbyyy/my_tools/my_views.dart';
  3. import 'package:cached_network_image/cached_network_image.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_svg/svg.dart';
  6. class PictureDisplayPage extends StatefulWidget {
  7. String imagePath;
  8. PictureDisplayPage(this.imagePath);
  9. @override
  10. _PictureDisplayPageState createState() => _PictureDisplayPageState();
  11. }
  12. class _PictureDisplayPageState extends State<PictureDisplayPage> {
  13. @override
  14. Widget build(BuildContext context) {
  15. return Scaffold(
  16. backgroundColor: Colors.black,
  17. body: Column(
  18. children: <Widget>[
  19. Expanded(
  20. child: GestureDetector(
  21. child: AsperctRaioImage.network(widget.imagePath,
  22. builder: (context, snapshot, url) {
  23. double h = (snapshot.data.height.toDouble() / 5);
  24. double w = (snapshot.data.width.toDouble() / 5);
  25. bool fw = h/w>=MediaQuery.of(context).size.height/MediaQuery.of(context).size.width;
  26. print('h-------------$h\nw----------------$w');
  27. return CachedNetworkImage(
  28. imageUrl: widget.imagePath,
  29. height: fw?h/w*MediaQuery.of(context).size.width:MediaQuery.of(context).size.height,
  30. width: fw?MediaQuery.of(context).size.width:w/h*MediaQuery.of(context).size.height,
  31. );
  32. }),
  33. onTap: () {
  34. Navigator.pop(context);
  35. },
  36. behavior: HitTestBehavior.translucent,
  37. ),
  38. )
  39. ],
  40. ),
  41. );
  42. }
  43. }