Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Disable Rotation failed in the Stack widget. #510

Open
bombert opened this issue Apr 13, 2022 · 0 comments
Open

[BUG] Disable Rotation failed in the Stack widget. #510

bombert opened this issue Apr 13, 2022 · 0 comments
Labels
bug Something isn't working
Projects

Comments

@bombert
Copy link

bombert commented Apr 13, 2022

Describe the bug

If there are two photo views in a stack and using a single controller, the first photo view's setting enableRotation and enablePanAlways would lose efficacy.

To Reproduce

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {


  late PhotoViewControllerBase controller;
  late PhotoViewScaleStateController scaleStateController;

  int calls = 0;

  @override
  void initState() {
    super.initState();
    controller = PhotoViewController()
      ..outputStateStream.listen(onController);
  }

  void onController(PhotoViewControllerValue value) {
    setState(() {
      calls += 1;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Stack(
          alignment: AlignmentDirectional.center,
          children: <Widget>[
            PhotoView(
              controller: controller,
              backgroundDecoration: BoxDecoration(color: Colors.transparent),
              imageProvider: AssetImage('assets/images/cross_star_full.png'),
              //initialScale: defScale,
              enableRotation: false,
              enablePanAlways: true,
            ),
            PhotoView(
              controller: controller,
              backgroundDecoration: BoxDecoration(color: Colors.transparent),
              imageProvider: AssetImage('assets/images/compass_red.png'),
              //initialScale: defScale,
              enableRotation: true,
              enablePanAlways: true,
            ),
          ],
        )
      ),
    );
  }
}

What is the current behavior?

Yes, when I update the flutter to 2.10 and met this issue.

Expected behavior

The first widget should not be rotated.

Screenshots

Screenshot_1651402459

Which versions of Flutter/Photo View, and which browser / OS are affected by this issue? Did this work in previous versions of Photo View?

flutter version is Flutter 2.10.4
Photo View is photo_view: ^0.13.0

@bombert bombert added the bug Something isn't working label Apr 13, 2022
@renancaraujo renancaraujo added this to Todo in Bug solving via automation May 24, 2022
@renancaraujo renancaraujo moved this from Todo to Needs triage in Bug solving May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Bug solving
  
Needs triage
Development

No branches or pull requests

1 participant