Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Last active January 27, 2021 20:45
Show Gist options
  • Save felipecastrosales/9efd6ab977b34690fc48499abf860a11 to your computer and use it in GitHub Desktop.
Save felipecastrosales/9efd6ab977b34690fc48499abf860a11 to your computer and use it in GitHub Desktop.
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