Business Login Flutter Apps
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

85 行
2.6 KiB

  1. import 'dart:io';
  2. import 'dart:typed_data';
  3. import 'package:image_picker/image_picker.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:photo_view/photo_view.dart';
  7. import '../Model/unit.dart';
  8. import '../main.dart';
  9. class PhotoViewer extends StatefulWidget {
  10. Uint8List byte;
  11. String? id;
  12. List<ImageType>? dropMenu;
  13. bool edit;
  14. String? jenis;
  15. PhotoViewer(this.byte,{this.id,this.edit= true,this.dropMenu,this.jenis});
  16. // PhotoViewer({Key key}) : super(key: key);
  17. @override
  18. _PhotoViewerState createState() => _PhotoViewerState();
  19. }
  20. class _PhotoViewerState extends State<PhotoViewer> {
  21. @override
  22. Widget build(BuildContext context) {
  23. return Column(
  24. children: <Widget>[
  25. Flexible(
  26. flex: 8,
  27. child: Container(
  28. child: Hero(
  29. tag: widget.id??'',
  30. child: PhotoView(
  31. imageProvider: MemoryImage(widget.byte),
  32. ),
  33. ),
  34. ),
  35. ),
  36. Expanded(
  37. flex: 1,
  38. child: Material(
  39. color: Colors.transparent,
  40. child: Container(
  41. child: Text(widget.jenis??'',style: TextStyle(color: Colors.white,fontSize: 18),),
  42. ),
  43. ),
  44. ),
  45. (widget.edit)?Flexible(
  46. flex: 1,
  47. child: Row(
  48. crossAxisAlignment: CrossAxisAlignment.center,
  49. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  50. children: <Widget>[
  51. TextButton(
  52. child: Text('Cancel'),
  53. style: TextButton.styleFrom(
  54. backgroundColor: Colors.red
  55. ),
  56. onPressed: (){Navigator.pop(context);},
  57. ),
  58. TextButton(
  59. child: Text('Change'),
  60. style: TextButton.styleFrom(
  61. backgroundColor: Colors.green
  62. ),
  63. onPressed: ()async{
  64. XFile? temp = await ImagePicker().pickImage(source: ImageSource.camera,maxWidth: 800);
  65. if(temp!=null){
  66. util.showLoading(context);
  67. widget.byte = await temp.readAsBytes();
  68. setState(() {
  69. });
  70. await Future.delayed(Duration(seconds: 1));
  71. }
  72. Navigator.pop(context);
  73. if(temp!= null)Navigator.pop(context,{'byte':widget.byte});
  74. },
  75. ),
  76. ],
  77. ),
  78. ):Container()
  79. ],
  80. );
  81. }
  82. }