需要PreferredSize中的问题这是我的代码:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('flutter'),
leading: IconButton(
icon: Icon(Icons.menu),
onPressed: () {
},
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {
},
),
IconButton(
icon: Icon(Icons.more_vert),
onPressed: () {
},
)
],
flexibleSpace: SafeArea(
child: Icon(
Icons.photo_camera,
size: 75.0,
color: Colors.white70
),
),
),
bottomSheet: (
PreferredSize(
child: Container(
color: Colors.blue,
height: 50.0,
child: Center(
child: Text('Mybutton')
)
),
)
),
body: null,
)
);
}
}发布于 2020-05-17 09:48:28
PreferredSize小部件需要一个PreferredSize,所以您应该声明它。它可以是fromWidth,fromHeight或fromRadius,我假设你需要你的情况下的高度,所以检查下面的代码并编写你喜欢的高度值而不是50。
PreferredSize(
preferredSize: Size.fromHeight(50),
child: Container(https://stackoverflow.com/questions/61845177
复制相似问题