Last active
January 27, 2021 20:45
-
-
Save felipecastrosales/9efd6ab977b34690fc48499abf860a11 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'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('FittedBox'), | |
centerTitle: true, | |
), | |
body: Container( | |
color: Colors.black, | |
alignment: Alignment.center, | |
child: FittedBox( | |
child: Row( | |
children: [ | |
MyWidget(), | |
MyImage(), | |
], | |
), | |
), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
color: Colors.green, | |
width: 100, | |
height: 100, | |
); | |
} | |
} | |
class MyImage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Image.network( | |
'https://images.pexels.com/photos/2131801/pexels-photo-2131801.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500', | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment