flutter OverflowBox溢出父容器显示示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
        title: "OverflowBox溢出父容器显示示例",
        home: Scaffold(
            appBar: AppBar(
              title: Text('OverflowBox溢出父容器显示示例'),
            ),
            body: Container(
              width: 200,
              height: 200,
              color: Colors.greenAccent,
              padding: EdgeInsets.all(10),
              child: OverflowBox(
                alignment: Alignment.topLeft,
                maxHeight: 300,
                maxWidth: 300,
                child: Container(
                  color: Colors.deepOrange,
                  width: 350,
                  height: 350,
                ),
              ),
            )));
  }
}