Android 为什么我的小部件没有';不要占用底部导航栏中的所有空间
我是一名新手,刚开始编写聊天应用程序的UI,因此我发现我的小部件并没有占用底部导航栏的所有空间,如图所示: 这是我的相机小部件代码:Android 为什么我的小部件没有';不要占用底部导航栏中的所有空间,android,flutter,frontend,Android,Flutter,Frontend,我是一名新手,刚开始编写聊天应用程序的UI,因此我发现我的小部件并没有占用底部导航栏的所有空间,如图所示: 这是我的相机小部件代码: import 'package:flutter/material.dart'; import 'dart:io'; import 'package:image_picker/image_picker.dart'; class Camera extends StatefulWidget { @override _CameraState createSt
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:image_picker/image_picker.dart';
class Camera extends StatefulWidget {
@override
_CameraState createState() => _CameraState();
}
class _CameraState extends State<Camera> {
File _image;
final imagePicker = ImagePicker();
Future getImage() async {
final image = await imagePicker.getImage(source: ImageSource.camera);
setState(() {
_image = File(image.path);
});
}
@override
Widget build(BuildContext context) {
return SizedBox(
height: 100,
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
width: 80.0,
height: 80.0,
child: FloatingActionButton(
backgroundColor: Colors.white,
onPressed: getImage,
child: Icon(
Icons.camera_alt_rounded,
color: Colors.lightBlue[600],
size: 35.0,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))),
),
),
],
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.lightBlue[50],
boxShadow: [
BoxShadow(color: Colors.grey[100], spreadRadius: 3),
],
),
height: 50,
),
);
}
}
导入“包装:颤振/材料.省道”;
导入“dart:io”;
导入“包:image_picker/image_picker.dart”;
类Camera扩展StatefulWidget{
@凌驾
_CameraState createState()=>\u CameraState();
}
类_CameraState扩展状态{
文件图像;
最终图像选择器=图像选择器();
Future getImage()异步{
最终图像=等待imagePicker.getImage(源:ImageSource.camera);
设置状态(){
_image=文件(image.path);
});
}
@凌驾
小部件构建(构建上下文){
返回大小框(
身高:100,
子:容器(
孩子:排(
mainAxisAlignment:mainAxisAlignment.space,
儿童:[
容器(
宽度:80.0,
身高:80.0,
子:浮动操作按钮(
背景颜色:Colors.white,
onPressed:getImage,
子:图标(
Icons.camera\u alt\u四舍五入,
颜色:颜色。浅蓝色[600],
尺寸:35.0,
),
形状:圆形矩形边框(
borderRadius:borderRadius.all(半径.圆形(20.0)),
),
),
],
),
装饰:盒子装饰(
边界半径:边界半径。圆形(20),
颜色:颜色。浅蓝色[50],
boxShadow:[
BoxShadow(颜色:Colors.grey[100],半径:3),
],
),
身高:50,
),
);
}
}
这是聊天屏幕代码:
import 'dart:io';
import 'package:mychat/services/auth.dart';
import 'package:flutter/material.dart';
import 'package:mychat/chat/chat.dart';
import 'package:mychat/widgets/Med_form.dart';
import 'package:mychat/widgets/bottomButtons.dart';
import 'package:mychat/widgets/camera.dart';
import 'package:mychat/widgets/increamentAndDecreament.dart';
import 'package:mychat/widgets/yesOrno.dart';
class ChatScreen extends StatefulWidget {
@override
_ChatScreenState createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
File _image;
final AuthService _auth = AuthService();
List<String> messages = [
'fizikefgzerpgr',
'fioezhfejzifojef',
'fvfzerfergnyolnkyokjy',
'rgop^l^lmf^prlgprgprp'
];
List<String> responses = [
'fizikefgzerpgr',
'fezfzefzefezff',
'ofpkoepzkfopkzef',
'fjeziofjiozejfozejf'
];
//final AuthService _auth = AuthService();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Directionality(
textDirection: TextDirection.rtl,
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(90),
child: AppBar(
title: new Text(
"لاباس ⸮",
style: TextStyle(
color: Colors.black,
fontSize: 30.0,
fontWeight: FontWeight.bold),
),
centerTitle: true,
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomRight,
colors: [Colors.blueGrey[300], Colors.grey[50]])),
),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.arrow_forward_ios_outlined,
color: Colors.black,
),
onPressed: () async {
await _auth.signOut();
})
],
elevation: 0.0,
),
),
body: Chat_page(messages: messages, responses: responses),
bottomNavigationBar: Camera(),
),
));
}
}
导入'dart:io';
导入“包:mychat/services/auth.dart”;
进口“包装:颤振/材料.省道”;
导入“包:mychat/chat/chat.dart”;
导入“package:mychat/widgets/Med_form.dart”;
导入“包:mychat/widgets/bottomButtons.dart”;
导入“包:mychat/widgets/camera.dart”;
导入“package:mychat/widgets/incrementanddecreament.dart”;
导入“package:mychat/widgets/yesOrno.dart”;
类ChatScreen扩展StatefulWidget{
@凌驾
_ChatScreenState createState()=>\u ChatScreenState();
}
类_ChatScreenState扩展状态{
文件图像;
最终AuthService_auth=AuthService();
列表消息=[
“fizikefgzerpgr”,
“Fioezhfeejzifojef”,
“Fvfzerfergnyolkyokjy”,
'rgop^l^lmf^prlgprgprp'
];
列表响应=[
“fizikefgzerpgr”,
“fezfzefzefezff”,
“OFPKOPZKFOPKZEF”,
“fjeziofjiozejfozejf”
];
//最终AuthService_auth=AuthService();
@凌驾
小部件构建(构建上下文){
返回材料PP(
家:方向性(
textDirection:textDirection.rtl,
孩子:脚手架(
appBar:首选大小(
首选尺寸:尺寸。从高度(90),
孩子:AppBar(
标题:新文本(
"لاباس ⸮",
样式:TextStyle(
颜色:颜色,黑色,
字体大小:30.0,
fontWeight:fontWeight.bold),
),
标题:对,
flexibleSpace:容器(
装饰:盒子装饰(
梯度:线性梯度(
开始:Alignment.topRight,
结束:对齐。右下角,
颜色:[颜色.蓝灰色[300],颜色.灰色[50]]),
),
行动:[
图标按钮(
图标:图标(
Icons.arrow\u forward\u ios\u概述,
颜色:颜色,黑色,
),
onPressed:()异步{
等待_auth.signOut();
})
],
标高:0.0,
),
),
正文:聊天页面(消息:消息,响应:响应),
底部导航栏:摄影机(),
),
));
}
}
这是信息的代码:
import 'package:bubble/bubble.dart';
import 'package:flutter/material.dart';
class Chat_page extends StatefulWidget {
List<String> messages;
List<String> responses;
Chat_page({this.messages, this.responses});
@override
_Chat_pageState createState() => _Chat_pageState();
}
class _Chat_pageState extends State<Chat_page> {
String message;
int data;
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
/* Container(
padding: EdgeInsets.only(top: 15, bottom: 10),
child: Text(
"Today, 10",
style: TextStyle(fontSize: 20, color: Colors.white),
),
), */
Flexible(
child: widget.messages.length > 0
? ListView.builder(
reverse: true,
shrinkWrap: true,
itemCount: widget.messages.length,
itemBuilder: (context, index) => Column(
children: [
widget.messages.length > 0
? chat(widget.messages[index].toString(), 1)
: Container(),
widget.responses.length > 0
? chat(widget.responses[index].toString(), 0)
: Container(),
],
))
: Container(),
),
SizedBox(
height: 20,
),
SizedBox(
height: 15.0,
)
],
));
}
}
Widget chat(String message, int data) {
return Container(
padding: EdgeInsets.only(left: 20, right: 20),
child: Row(
mainAxisAlignment:
data == 1 ? MainAxisAlignment.end : MainAxisAlignment.start,
children: [
data == 0
? Container(
height: 60,
width: 60,
child: CircleAvatar(
child: Icon(Icons.account_circle),
),
)
: Container(),
Padding(
padding: EdgeInsets.all(10.0),
child: Bubble(
radius: Radius.circular(15.0),
color: data == 0 ? Color(0xFFf7ede2) : Color(0xFFf7ede2),
elevation: 0.0,
child: Padding(
padding: EdgeInsets.all(2.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
width: 10.0,
),
Flexible(
child: Container(
constraints: BoxConstraints(maxWidth: 200),
child: Text(
message,
style: TextStyle(
color: Colors.black, fontWeight: FontWeight.bold),
),
))
],
),
)),
),
data == 1
? Container(
height: 60,
width: 60,
child: CircleAvatar(
child: Icon(Icons.account_circle),
),
)
: Container(),
],
),
);
}
导入“包:bubble/bubble.dart”;
进口“包装:颤振/材料.省道”;
类聊天页面扩展StatefulWidget{
列出信息;
列出答复;
聊天页面({this.messages,this.responses});
@凌驾
_Chat_pageState createState()=>_Chat_pageState();
}
类_Chat_pageState扩展状态{
字符串消息;
int数据;
@凌驾
小部件构建(构建上下文){
返回容器(
子:列(
儿童:[
/*容器(
填充:仅限边缘设置(顶部:15,底部:10),
子:文本(
“今天,10”,
样式:TextStyle(字体大小:20,颜色:Colors.white),
),
), */
灵活的(
子项:widget.messages.length>0
?ListView.builder(
相反:是的,
收缩膜:对,
itemCount:widget.messages.length,
itemBuilder:(上下文,索引)=>列(
儿童:[
widget.messages.length>0
?聊天(widget.messages[index].toString(),1)
:Container(),
widget.responses.length>0
?聊天(widget.responses[index].toString(),0)
:Container(),
],
))
:Container(),
),
大小盒子(
身高:20,
),
大小盒子(
身高:15.0,
)
],
));
}
}
小部件聊天(字符串消息、int数据){
返回容器(
填充:仅限边缘设置(左:20,右:20),
孩子:排(
主轴对准:
数据==1?MainAxisAlignment.end:MainAxisAlignment.start,
儿童:[
数据==0
?容器(
SizedBox(
height: 100,
child: Container(
Container(
height: 100,
width:double.infinty,