Created
December 27, 2019 01:31
-
-
Save JCzz/f9e2ae58b0e987317a66875e95b75fc3 to your computer and use it in GitHub Desktop.
This file contains 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 'package:flutter/rendering.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
static const String _title = 'Flutter Code Sample'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: _title, | |
home: MyStatefulWidget(), | |
); | |
} | |
} | |
class MyStatefulWidget extends StatefulWidget { | |
MyStatefulWidget({Key key}) : super(key: key); | |
@override | |
_MyStatefulWidgetState createState() => _MyStatefulWidgetState(); | |
} | |
// State | |
class _MyStatefulWidgetState extends State<MyStatefulWidget> { | |
Matrix4 matrix = Matrix4.identity(); | |
double fitWidth; | |
@override | |
void initState() { | |
fitWidth = 0; | |
super.initState(); | |
} | |
double screenSizeWidth(BuildContext context) { | |
if (fitWidth != 0) { | |
return fitWidth; | |
} else { | |
return MediaQuery.of(context).size.width; | |
} | |
} | |
Widget build(BuildContext context) { | |
var sizWWidth = screenSizeWidth(context); | |
print(sizWWidth); | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('Sample Code'), | |
), | |
body: Transform.scale( | |
scale: 0.5, | |
child: Container( | |
color: Colors.red, | |
width: sizWWidth, | |
height: 400, | |
), | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: () { | |
setState(() { | |
fitWidth = 800; | |
}); | |
// Add your onPressed code here! | |
}, | |
backgroundColor: Colors.green, | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment