我无法控制键盘显示或隐藏,在我的项目中,我需要始终隐藏键盘但保持专注以显示我的自定义键盘(小部件)。
这是我想要的

这是我的问题

由于我们android:textAllCaps="true"在 Android 的 Textview中有功能,我们如何在Flutter 的Text() Widget 中提供相同的功能?
我知道Text('Abc'.toUpperCase()),这是一种方式,但我不想手动完成。是否有 Text() 小部件的任何属性可以自动转换它或任何具有类似属性的小部件?
我希望图标details向上指向,如图所示。但是材质图标列表中有图标details指向下方,那么如何在不下载图标图像的情况下旋转我的flutter项目中的材质图标。
Column(
children: <Widget>[
Container(
height: 48,
decoration: BoxDecoration(
color: Color(0xFFFBBC05),
borderRadius: BorderRadius.circular(48),
boxShadow: [
BoxShadow(
blurRadius: 16,
offset: Offset(0, 8),
color: Color(0XFFFBBC05),
spreadRadius: -10)
]),
child: IconButton(
icon: Icon(
Icons.details,
color: Colors.white,
),
onPressed: null,
),
),
SizedBox(
height: 8,
),
Text(
"Historical",
style: TextStyle(fontFamily: 'AirbnbCerealMedium', fontSize: 12),
),
],
)
Run Code Online (Sandbox Code Playgroud) 在 flutter 1.22 更新后,我在 Lineargradient 颜色属性中收到一个错误,它给我一个错误,即名称颜色参数未定义..在 android 中的 flutter 和 flutter 插件更新后,我在项目中的任何地方都收到此错误工作室。
dart flutter flutter-dependencies flutter-layout flutter-animation
我想创建一个水平滚动列表,当从左侧或右侧滑动时,使用捕捉以适应效果.
每张卡片之间有一些间距,适合屏幕,类似于下图
除此之外,这些可水平滚动的列表元素应包含在垂直可滚动列表中.
我所能实现的只是在flutter docs中跟随示例之后才显示水平滚动卡列表.
class SnapCarousel extends StatelessWidget {
@override
Widget build(BuildContext context) {
final title = 'Horizontal List';
return MaterialApp(
title: title,
home: Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Container(
margin: EdgeInsets.symmetric(vertical: 20.0),
height: 200.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
Container(
width: 160.0,
color: Colors.red,
),
Container(
width: 160.0,
color: Colors.blue,
),
Container(
width: 160.0,
color: Colors.green,
),
Container(
width: 160.0,
color: Colors.yellow,
),
Container(
width: 160.0,
color: Colors.orange,
),
],
),
),
),
);
} …Run Code Online (Sandbox Code Playgroud) dart flutter flutter-sliver flutter-layout flutter-animation
我在Flutter中的BottomNavigationBar有问题。如果要更改标签,我想让页面保持活动状态。
这是我的实现
底部导航
class Home extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _HomeState();
}
}
class _HomeState extends State<Home> {
int _currentIndex = 0;
List<Widget> _children;
final Key keyOne = PageStorageKey("IndexTabWidget");
@override
void initState() {
_children = [
IndexTabWidget(key: keyOne),
PlaceholderWidget(Colors.green),
NewsListWidget(),
ShopsTabWidget(),
PlaceholderWidget(Colors.blue),
];
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(MyApp.appName),
textTheme: Theme.of(context).textTheme.apply(
bodyColor: Colors.black,
displayColor: Colors.blue,
),
),
body: _children[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
onTap: onTabTapped,
key: IHGApp.globalKey,
fixedColor: Colors.green,
type: BottomNavigationBarType.fixed,
currentIndex: …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建ListView,但是当我导入list_form.dart类时,出现此错误。也许我在布局上犯了一些错误,因为如果尝试在主文件中运行它,我不会得到此错误。
这是错误:
I/flutter (12956): ??? EXCEPTION CAUGHT BY RENDERING LIBRARY ??????????????????????????????????????????????????????????
I/flutter (12956): The following assertion was thrown during performResize():
I/flutter (12956): Vertical viewport was given unbounded height.
I/flutter (12956): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter (12956): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (12956): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (12956): If this widget …Run Code Online (Sandbox Code Playgroud) 我对crossAxisAlignment和感到困惑mainAxisAlignment。谁能用简单的话解释一下?
我需要为我的 API 发送我的令牌。我将我的令牌保存在 SharedPreferences 中,我可以恢复它。我的 API 需要一个,带有 Bearer 但怎么做?
我用授权、Http 等进行了测试。
在SP中保存的方法
Future<bool> setToken(String value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.setString('token', value);
}
Future<String> getToken() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getString('token');
}
Future<Candidate> candidateAuth({Map map}) async {
String url = 'http://10.0.2.2:3000/v1/api/auth/candidate';
await http
.post(url,
headers: {
'Content-type': 'application/json',
'Accept': 'application/json'
},
body: jsonEncode(map))
.then((response) {
if (response.statusCode == 201) {
token = Candidate.fromJson(json.decode(response.body)).token;
Candidate().setToken(token);
return Candidate.fromJson(json.decode(response.body));
} else {
throw Exception('Failed auth'); …Run Code Online (Sandbox Code Playgroud) 在项目中,我在 flutter 卡片中使用了图像和文本,但卡片返回了一个固定的高度。然后我也尝试只使用带有空值的卡片,但它仍然返回一个固定的高度。我该怎么做才能使卡片的高度随内容自动调整?
@覆盖
小部件构建(BuildContext 上下文){
final title = '食物食谱';
返回 MaterialApp(
标题:标题,
主页: 脚手架(
应用栏:应用栏(
标题:文本(标题),
),
正文:GridView.builder(
itemCount: _listViewData.length,
网格委托:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
itemBuilder:(上下文,索引){
退货卡(
边距:const EdgeInsets.all(10.0),
孩子:列(
crossAxisAlignment: CrossAxisAlignment.start,
孩子们: [
纵横比(
纵横比:18.0 / 13.0,
孩子:Image.network(
_listViewDataImage[索引],
适合:BoxFit.fill,
),
),
填充(
填充:EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 8.0),
孩子:列(
crossAxisAlignment: CrossAxisAlignment.start,
孩子们: [
文本(
_listViewData[索引],
textAlign: TextAlign.center,
),
],
),
),
],
),
);
}),
),
);
}