在颤振中,我想在我的应用程序中使用一个小部件,如果不满足条件,则会打印屏幕上不包含空间的容器(或任何其他小部件)。实际上我想要一个在颤动中不覆盖屏幕上空间的小部件。
我正在 ios 模拟器中运行我的应用程序,但为什么当我单击文本字段时我的键盘突然不显示?在我修复我的应用程序图标之前,它工作得很好。
尝试删除该应用并重新安装,但仍然不起作用。当我在 Android 上运行该应用程序并单击同一文本字段时,会显示键盘。
这是代码:
TextField(
keyboardType: TextInputType.multiline,
controller: inputTextController,
onChanged: (text) {
if (!_isWriting){
_isWriting = true;
//update typing status when type messages
var msg = {};
msg["api_key"] = apiKey;
msg["type"] = "status_typing";
msg["id_sender"] = idUser;
msg["id_receiver"] = idReceiver;
msg["room_id"] = conversation!.roomId;
String msgString = json.encode(msg);
homes.channel.sink.add(msgString);
setState((){});
Future.delayed(Duration(seconds: 2)).whenComplete((){
_isWriting = false;
setState((){});
});
}
},
maxLines: null,
style: TextStyle(
color: Colors.black,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 13, bottom: 13),
border: InputBorder.none,
hintText: 'Type a message', …Run Code Online (Sandbox Code Playgroud) 我在设计 flutter 程序时遇到了麻烦。
当我运行程序并调整程序大小时,一切都崩溃并且不正常。
你可以在下图中看到。

我想添加自定义启动屏幕,但在此之前显示的默认启动屏幕看起来太奇怪了
我正在从图库中获取图像并使用 Image.memory() 将其显示在我的裁剪器中。但有时(对于大文件)图像需要几秒钟的时间才能显示。我想显示加载动画,但如何检测它何时加载或完成?没有像 Image.network() 这样的loadingBuilder。有任何想法吗?
final XFile? image = await _picker.pickImage(source: ImageSource.gallery);
Image.memory(_imageToCrop!)
Run Code Online (Sandbox Code Playgroud) 我有一个row包含 的列表circle avatars widgets,其中是人员的个人资料图片。
Row(children: [
for (var i in listOfEvents[i].attendeesList)
CircleAvatar(
backgroundImage: NetworkImage("https://github.com/identicons/guest.png"),
radius: 18,
),
],
)
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种方法将所有圆形头像向左移动一点,以便头像看起来像是彼此叠在一起以节省空间
就像这个插图
我一直在尝试使用添加负填充或负位置,Padding widget但它不起作用
如果有人知道如何做到这一点那就太好了!
我有一个容器,我试图打印出列表中的项目,减去列表中的最后一个项目。我正在使用 list.generate:
child: Container(
width: double.infinity,
color: Colors.white,
child: ListView(
padding: const EdgeInsets.only(top: 10.0),
children: List.generate(
Provider.of<WeekList>(context).listOfWeeks.toList().length -
1,
(index) => ListTileCustom(
index: index,
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
我的问题是,当它打印出我的自定义ListTileCustom小部件时,添加到列表中的每个新项目都会添加到视图的底部而不是顶部。
上图中的顺序应该是:
当我通过按下按钮添加新项目时,它们应该添加到顶部而不是底部。
我尝试添加reverse: true,这得到了正确的顺序,但将所有内容移动到底部并在它们上面添加了大量的空白...也不确定滚动在那时是否会在正确的方向上工作。
1. 说明
我想更改“SizedBox”的完整颜色以查看“SizedBox”的位置和范围。我想知道有什么方法可以改变 SizedBox 的颜色而不用容器或装饰框填充它。如果没有,我想知道如何用装饰框填充SizedBox。
2. 代码
这是我尝试过的代码。
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home : Scaffold(
appBar: AppBar(
title : const Text('this is title'),
),
body : const SizedBox(
width : 200,
child: DecoratedBox(
decoration: BoxDecoration(
color : Colors.red,
),
),
),
bottomNavigationBar: (
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.favorite),
Icon(Icons.home),
Icon(Icons.settings)
],
)
),
),
);
} …Run Code Online (Sandbox Code Playgroud) 我有一个导航按钮,单击该按钮后应该打开 Google 地图或 Apple 地图应用程序(以安装的为准),并显示从当前位置到目的地位置的导航方向
我使用url_launcher包尝试了以下方法
await launchUrlString("https://www.google.com/maps/dir/?api=1&origin=${position.latitude},${position.longitude}&destination=${vendorPosition.latitude},${vendorPosition.longitude}");
await launchUrl(Uri.parse("google.navigation:q=${position.latitude},${position.longitude}&mode=d"));
这两种方法都没有按预期工作,特别是因为这仅使用谷歌地图 URI
navigation google-maps android-intent flutter flutter-layout
flutter ×10
flutter-layout ×10
dart ×2
google-maps ×1
listview ×1
mobile ×1
navigation ×1
windows ×1