1.源代码
import ‘package:flutter/material.dart’;
void main () => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State {
GlobalKey globalKey = new GlobalKey();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flex(
direction: Axis.horizontal,
children: [
Expanded(
flex: 1,
child: Container(
height: 50.0,
color: Colors.orange,
),
),
Spacer(
flex: 1,
),
Expanded(
flex: 2,
child: Container(
height: 50.0,
color: Colors.green,
),