我正在尝试在底部导航栏的中间添加一个浮动操作按钮。问题是边框没有出现,浮动操作按钮和图标中的边距也不符合我的要求。
这是问题的图片。 实现的图像
这是我想要的 图片 所需图片
代码
bottomNavigationBar: SafeArea(child: _buildBottomBar(context)),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: CircularGradientButton(
tooltip: 'Increment',
child: new Image.asset(UIData.cameraIcon),
gradient: LinearGradient(colors: <Color>[
Color.fromARGB(255, 17, 153, 142),
Color.fromARGB(255, 56, 239, 125)
]),
callback: () => openCamera(),
//_optionsDialogBox(),
elevation: 2.0,
),
Widget _buildBottomBar(BuildContext context) {
return Material(
color: Colors.white,
child: TabBar(
isScrollable: false,
unselectedLabelColor: Colors.white.withOpacity(0.3),
indicatorColor: Colors.white,
tabs: <Tab>[
new Tab(
// set icon to the tab
icon: Image.asset(
_tabController.index == 0 ? UIData.mapIconActive : UIData.mapIcon,
width: 30,
height: 30,
),
), …Run Code Online (Sandbox Code Playgroud) 我正在开发 Flutter 应用程序。我需要相机功能并决定为此使用相机插件。我将纵横比设置为 3:4,但图像扭曲且小于应有的尺寸。我认为规模有问题。设置相机纵横比(即 3:4)的正确方法是什么?
final size = MediaQuery.of(context).size;
final deviceRatio = size.width / size.height;
final aspectRatio=3/4;
Transform.scale(
scale: controller.value.aspectRatio / deviceRatio,
child: Center(
child: AspectRatio(
aspectRatio: aspectRatio,
child: CameraPreview(controller),
)
),
)
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中有一个谷歌地图。我为此使用了google_maps_flutter。我想在右上角添加通知图标。我尝试使用 Stack 但 Google Map 覆盖了图标。
代码
Scaffold(
resizeToAvoidBottomInset: true,
body: Stack(
children: <Widget>[
Positioned(
top: 60,
right: 40,
child: IconButton(
icon: new Image.asset(UIData.notificationIcon),
onPressed: () {},
)),
GoogleMap(
myLocationEnabled: true,
myLocationButtonEnabled: true,
mapType: MapType.normal,
initialCameraPosition: _kGooglePlex,
markers: Set<Marker>.of(markers.values),
onMapCreated: (controller) {
if (this.mounted)
setState(() {
myController = controller;
});
})
],
),
);
Run Code Online (Sandbox Code Playgroud) 我有一个带有评论项的 ListView,每个评论都有一个带有评论回复的新 ListView,我使用了 Firebase,当我回复评论时,它在 ListView 上显示错误的文本,但在控制台中打印了正确的文本。当我返回并再次出现时,它会显示正确的值。观看视频以了解详情。
Padding(
padding: EdgeInsets.only(left: 0.0),
child: StreamBuilder(
stream: getCommentReply(listMessage[index]['id']),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(child: Text(''));
}
var listReplyMessage = snapshot.data.documents;
return Padding(
padding: EdgeInsets.only(top: 8.0),
child: commentsReplyItems(listReplyMessage,
snapshot, listMessage[index]['id']));
}))
Widget commentsReplyItems(
var listMessage, AsyncSnapshot snapshot, String commentID) {
return CommentReplay(
listMessage, snapshot, commentID, widget.currentUser, widget.postID);
}
Stream<QuerySnapshot> getCommentReply(String msgID) {
Stream<QuerySnapshot> _query = Firestore.instance
.collection('Posts')
.document(widget.postID)
.collection('Comments')
.document(msgID)
.collection('Reply')
.orderBy('created_at', descending: true)
.limit(2)
.snapshots();
return _query;
}
Run Code Online (Sandbox Code Playgroud)
评论 …