Skip to content

Instantly share code, notes, and snippets.

@AlexV525
Created April 17, 2020 09:18
Show Gist options
  • Save AlexV525/d9cb96dcf4645d969862e4b23fc4d4f3 to your computer and use it in GitHub Desktop.
Save AlexV525/d9cb96dcf4645d969862e4b23fc4d4f3 to your computer and use it in GitHub Desktop.
Flutter IntrinsicHeight demo.
// 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: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
IntrinsicHeight(
child: Row(
children: <Widget>[
Container(
width: 100,
child: Text(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test',
maxLines: null,
overflow: TextOverflow.visible,
),
),
Expanded(
child: Container(
color: Colors.red,
child: Center(child: Text('Fit container through IntrinsicHeight')),
),
),
],
),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment