Created
November 13, 2020 07:02
-
-
Save imaNNeo/f143b4c0ff9b535eb64ba7ca31f04425 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:math' as math; | |
void main() { | |
runApp(MyApp()); | |
} | |
// Degree / Radians converter | |
const double degrees2Radians = math.pi / 180.0; | |
const double radians2Degrees = 180.0 / math.pi; | |
double degrees(double radians) => radians * radians2Degrees; | |
double radians(double degrees) => degrees * degrees2Radians; | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter 4 Fun', | |
home: MainPage(), | |
); | |
} | |
} | |
class MainPage extends StatefulWidget { | |
@override | |
_MainPageState createState() => _MainPageState(); | |
} | |
class _MainPageState extends State<MainPage> { | |
double rotationY = 0; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Color(0xffFF6958), | |
body: Column( | |
children: [ | |
Expanded( | |
child: Container( | |
child: Center( | |
child: Text( | |
'Flutter4Fun.com', | |
style: TextStyle( | |
color: Colors.white, | |
), | |
), | |
), | |
)), | |
Transform( | |
alignment: FractionalOffset.center, | |
transform: Matrix4.identity() | |
..setEntry(3, 2, 0.01) | |
..rotateY(radians(rotationY)), | |
child: Container( | |
height: 180, | |
color: Colors.white.withOpacity(0.4), | |
margin: EdgeInsets.symmetric(horizontal: 40), | |
), | |
), | |
Expanded(child: Container()), | |
Text( | |
'${rotationY.toInt()} degrees', | |
style: TextStyle( | |
color: Colors.white, | |
fontWeight: FontWeight.bold, | |
), | |
), | |
Slider( | |
value: rotationY, | |
onChanged: (value) { | |
setState(() { | |
rotationY = value; | |
}); | |
}, | |
min: 0, | |
max: 180, | |
) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment