Photo_view: scaleStateController of PhotoViewGalleryPageOptions doesn't work

Created on 25 May 2019  路  4Comments  路  Source: fireslime/photo_view

Both PhotoViewController and PhotoViewScaleStateController seem to work fine in PhotoView, but in PhotoViewGalleryPageOptions, PhotoViewScaleStateController sends no events.

You can run the code below and check that printScaleState is never called.

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Foo()
      ),
    );
  }
}

class Foo extends StatefulWidget {
  @override
  _FooState createState() => _FooState();
}

class _FooState extends State<Foo> {
  static const images = <String>[
    'https://homepages.cae.wisc.edu/~ece533/images/peppers.png',
    'https://homepages.cae.wisc.edu/~ece533/images/baboon.png',
    'https://homepages.cae.wisc.edu/~ece533/images/girl.png',
  ];

  PhotoViewScaleStateController scaleStateController;

  @override
  void initState() {
    super.initState();
    scaleStateController = PhotoViewScaleStateController()
      ..outputScaleStateStream.listen(printScaleState);
  }

  void printScaleState(PhotoViewScaleState scaleState) =>
      print('scaleState: $scaleState');

  @override
  void dispose() {
    scaleStateController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return PhotoViewGallery.builder(
      itemCount: images.length,
      builder: (_, int index) {
        return PhotoViewGalleryPageOptions(
          imageProvider: NetworkImage(images[index]),
          scaleStateController: scaleStateController,
        );
      },
    );
  }
}
bug

All 4 comments

馃槯 Thats is a huge failure, publishing fix

A fix for that has been included on master, since photoview 0.4.0 is not yet beta compatible, I wont publish any release for now. However, you can depend directly on our master to get that fix.

@renancaraujo Flutter has reached 1.7.8 in stable channel. Perhaps you should consider publishing a new release.

Doing it ASAP

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darrylong picture darrylong  路  5Comments

barangungor picture barangungor  路  7Comments

renancaraujo picture renancaraujo  路  4Comments

bombert picture bombert  路  9Comments

bierbaumtim picture bierbaumtim  路  7Comments