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

Rotation does not work properly when using custom child. #92

Closed
janniklind opened this issue Feb 3, 2019 · 1 comment
Closed

Rotation does not work properly when using custom child. #92

janniklind opened this issue Feb 3, 2019 · 1 comment
Labels
bug Something isn't working Custom child

Comments

@janniklind
Copy link

janniklind commented Feb 3, 2019

Hi.

I am trying to get the rotation to work with a custom child, however it seems that the point it rotates around is wrong. I would expect it to rotate around the center point of the custom child.

See the example below. It is the original RotationExample, however with the original custom child from the CustomChildExample.

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

class RotationExamples extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          const ExampleAppBar(
            title: "Rotation Example",
            showGoBack: true,
          ),
          Expanded(
              child: Column(
            children: <Widget>[
              Container(
                padding: const EdgeInsets.all(20.0),
                child: const Text(
                  "Example using option enableRotation, just pinch an rotate",
                  style: const TextStyle(fontSize: 18.0),
                ),
              ),
              Container(
                  margin: const EdgeInsets.symmetric(vertical: 20.0),
                  height: 300.0,
                  child: ClipRect(
                    /*
                    child: PhotoView(
                      imageProvider: const AssetImage("assets/large-image.jpg"),
                      maxScale: PhotoViewComputedScale.covered,
                      initialScale: PhotoViewComputedScale.contained * 0.8,
                      enableRotation: true,
                    )
                    */
                    child: PhotoView.customChild(
                      child: Container(
                          decoration:
                          const BoxDecoration(color: Colors.lightGreenAccent),
                          padding: const EdgeInsets.all(10.0),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                              const Text(
                                "Hello there, this is a text, that is a svg",
                                style: const TextStyle(fontSize: 10.0),
                                textAlign: TextAlign.center,
                              ),
                              SvgPicture.asset(
                                "assets/firefox.svg",
                                height: 100.0,
                              )
                            ],
                          )),
                      childSize: const Size(220.0, 250.0),
                      initialScale: 1.0,
                      enableRotation: true,
                    )
                  )
              ),
            ],
          ))
        ],
      ),
    );
  }
}
@renancaraujo renancaraujo added the bug Something isn't working label Feb 4, 2019
@renancaraujo
Copy link
Member

Fixed on 0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Custom child
Projects
None yet
Development

No branches or pull requests

2 participants