Skip to content

Instantly share code, notes, and snippets.

@pietervp
Last active November 24, 2021 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pietervp/140761e528a780ac520fed7c430843b2 to your computer and use it in GitHub Desktop.
Save pietervp/140761e528a780ac520fed7c430843b2 to your computer and use it in GitHub Desktop.
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
HomePage() : super(); // changed
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Offset _offset = Offset(0.2, 0.6);
@override
Widget build(BuildContext context) {
return Transform(
transform: Matrix4.identity()
..setEntry(3, 2, 0.001)
..rotateX(0.01 * _offset.dy)
..rotateY(-0.01 * _offset.dx),
alignment: FractionalOffset.center,
child: GestureDetector(
onPanUpdate: (details) => setState(() => _offset += details.delta),
onDoubleTap: () => setState(() => _offset = Offset(0.2, 0.6)),
child: _app(context),
)
);
}
_app(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue[200],
appBar: AppBar(
title: Text('Perspective 3D Demo'),
),
body: Center(
child: Column(
children: [
Image.network("https://scontent-bru2-1.xx.fbcdn.net/v/t1.6435-9/88423283_2944285712276957_1169081946123272192_n.png?_nc_cat=111&ccb=1-5&_nc_sid=09cbfe&_nc_ohc=nk4TkEMKj-kAX_KzrRE&_nc_oc=AQlYL0osvgs0bAsfwkPbTtCcCMrxOwOGYaYblkPkQZV-WcN6Wf8G5q8Zsvlu_Lv1e90&_nc_ht=scontent-bru2-1.xx&oh=d69441344c0431d04d9dfa52b59bc8d4&oe=61C32B30",scale: 1.5,),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment