Flutter Fatter中Facebook的评论框
这是我的代码Flutter Fatter中Facebook的评论框,flutter,Flutter,这是我的代码 TextField( controller: commentController, maxLines: 3, selectionHeightStyle: BoxHeightStyle.tight, decoration: new InputDecoration( hintText: 'Write a Comment',
TextField(
controller: commentController,
maxLines: 3,
selectionHeightStyle: BoxHeightStyle.tight,
decoration: new InputDecoration(
hintText: 'Write a Comment',
hintStyle: new TextStyle(
color: Colors.grey,
),
prefixIcon: InkWell(
child: Icon(Icons.camera_alt),
onTap: () {
chooseImage();
},
),
suffixIcon: InkWell(
child: Icon(
Icons.send,
),
onTap: () {
if (filePickedName == 'nofile') {
insertMethod();
commentController.clear();
_fleshScreen();
getCommentData();
} else {
upload();
commentController.clear();
_fleshScreen();
getCommentData();
}
},
)),
style: new TextStyle(
color: Colors.black,
),
),
我想用ImageView创建此框
让我给你一个小部件
class CommentBox扩展了StatefulWidget{
最终窗口小部件图像;
最终文本编辑控制器;
最终边界半径输入;
最终函数onSend,onImageRemoved;
const CommentBox({Key,this.image,this.controller,this.inputRadius,this.onSend,this.onImageRemoved}):super(Key:Key);
@凌驾
_CommentBoxState createState();
}
类CommentBoxState扩展了状态{
小部件图像;
@凌驾
void initState(){
image=widget.image;
super.initState();
}
@凌驾
小部件构建(构建上下文){
返回列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
分隔器(
身高:1,,
颜色:颜色。灰色[300],
厚度:1,
),
const SizedBox(高度:20),
如果(图像!=null)
_可移动(
上下文
_图像视图(上下文),
),
if(widget.controller!=null)TextFormField(
控制器:widget.controller,
装饰:输入装饰(
后缀:图标按钮(
icon:icon(Icons.send,color:Theme.of(context.primaryColor,),
onPressed:widget.onSend,
),
是的,
边框:大纲输入边框(
borderSide:borderSide.none,
borderRadius:widget.inputRadius??borderRadius.circular(32),
),
),
),
],
);
}
小部件可移动(构建上下文,小部件子项){
返回堆栈(
对齐:alignment.topRight,
儿童:[
小孩
图标按钮(
图标:图标(图标。清除),
已按下:(){
设置状态(){
image=null;
onImageRemoved();
});
},
)
],
);
}
Widget\u imageView(构建上下文){
返回填充(
填充:边缘设置。全部(16),
孩子:ClipRRect(
边界半径:边界半径。圆形(16),
孩子:图像,
),
);
}
}
像任何小部件一样使用它
MaterialApp(
家:脚手架(
正文:安全区(
子:列(
儿童:[
尺寸箱(高度:128,),
垫片(),
评论框(
image:image.asset(
“assets/svg/barber.svg”,
身高:64,
宽度:64,
),
控制器:TextEditingController(),
onImageRemoved:(){
//在删除图像时
},
onSend:(){
//按下发送按钮
},
),
],
),
),
),
)