import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; import 'package:http/http.dart' as http; // リスト 6.5_cf void main() => runApp(ImagePage()); class ImagePage extends StatelessWidget { double? scale; double? rotation; void listener(PhotoViewControllerValue value) { if (value.scale != null) { scale = value.scale!; } rotation = value.rotation; } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('ImagePage') ), body: Center( child: PhotoView( imageProvider: Image.network('https://flutter.github.io' '/assets-for-api-docs/assets/widgets/owl.jpg').image, enableRotation: true, controller: PhotoViewController() ..outputStateStream.listen(listener), backgroundDecoration: BoxDecoration(color: Colors.transparent) ) ) ) ); } // リスト 6.7 Future<http.Response> execute(String account, String name) async { final uri = Uri.https('path', 'v1.0/example'); return await http.post( uri, headers: {'X-Api-Key': account}, body: {'name': name} ); } }