I can't seem get proper gesture detection when applying a Matrix to a widget. My best guess is that it has something to do with FractionallySizedBox.
Here is a MCVE:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
final double scaleFactor = size.aspectRatio;
final Matrix4 matrix = Matrix4.diagonal3Values(scaleFactor, scaleFactor, 1.0);
return Scaffold(
backgroundColor: Colors.red.shade100,
body: Center(
child: Container(
width: size.width,
height: size.height * scaleFactor,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Container(
transform: matrix,
child: FractionallySizedBox(
widthFactor: 1 / scaleFactor,
heightFactor: 1 / scaleFactor,
alignment: AlignmentDirectional.topStart,
child: Row(
children: <Widget>[
Expanded(
child: Container(
width: size.width,
height: size.height,
child: const Page(
title: 'PageA',
),
),
),
const SizedBox(width: 16.0),
Expanded(
child: Container(
width: size.width,
height: size.height,
child: const Page(
title: 'PageB',
),
),
),
],
),
),
),
),
),
);
}
}
class Page extends StatelessWidget {
const Page({Key key, @required this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: FlatButton(
child: const Text('Press me'),
onPressed: () {
print('$title onPressed');
},
),
);
}
}
