The SizedOverflowBox
is to provide a specific size, but passes its original constraints through to its child, which may then overflow.
The default constructor creates a widget of a given size that lets its child overflow.
The size
argument must not be null.
SizedOverflowBox(
size: // required
alignment: Alignment.center,
child:
)
It contains many input parameters which can be configured to change its behavior and appearance.
The size
parameter is to size this widget should attempt to be.
The alignment
parameter is to add alignment to child both horizontally and vertically.
The child
parameter is to add the widget below LimitedBox in a tree.
The following code snippet shows how to configure SizedOverflowBox
widget.
SizedOverflowBox(
size: Size(50, 50),
child: Container(
width: 100,
height: 100,
color: Colors.blue,
child: Text('SizedOverflowBox widget demo'),
),
),
This example shows this widget creates a size of 50x50 and its child overflows by size 100x100.
import 'package:flutter/material.dart';
class SizedOverflowBoxDemo extends StatelessWidget {
Widget build(BuildContext context) {
return Center(
child: SizedOverflowBox(
size: Size(50, 50),
child: Container(
width: 100,
height: 100,
color: Colors.blue,
child: Text('SizedOverflowBox widget demo'),
),
),
);
}
}
class MyApp extends StatelessWidget {
static const String _title = 'SizedOverflowBox Demo';
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: SizedOverflowBoxDemo(),
),
);
}
}
void main() => runApp(MyApp());