リスト 6.5


import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

// リスト 6.5
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 Scaffold(
      appBar: AppBar(
        title: Text('ImagePage')
      ),
      body: Center(
        child: PhotoView(
          imageProvider: Image.network('画像のURL').image,
          enableRotation: true,
          controller: PhotoViewController()
                        ..outputStateStream.listen(listener),
          backgroundDecoration: BoxDecoration(color: Colors.transparent)
        )
      )
    );
  }
}