flutter - 在 Flutter 中删除边框轮廓?
问题描述
我正在实现一个切换小部件,并试图使边框变圆,我现在似乎有边框轮廓。我不太确定如何禁用它们。
如您所见,在“Bug”旁边,您有方角轮廓。
我的代码:
Container(
height: 30,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.3),
borderRadius: BorderRadius.all(Radius.circular(20))),
child: ToggleButtons(
isSelected: isSelected,
selectedColor: Colors.orange[600],
color: Colors.black,
fillColor: Colors.white,
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text('Bug',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18))),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text('Improvement', style: TextStyle(fontSize: 18))),
]
希望得到一些帮助,在此先感谢!
解决方案
根据您的要求,我创建了一个自定义设计,请检查并让我知道它是否有效
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool _isItemSelected = true;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: double.infinity,
height: 40,
margin: EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
color: Colors.grey[350],
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
_isItemSelected = !_isItemSelected;
});
},
child: Container(
margin: EdgeInsets.symmetric(horizontal: 5, vertical: 5),
height: 35,
decoration: BoxDecoration(
color:
_isItemSelected ? Colors.white : Colors.transparent,
borderRadius: BorderRadius.circular(5),
boxShadow: _isItemSelected
? [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset:
Offset(0, 3), // changes position of shadow
),
]
: null,
),
child: Center(
child: Text(
'Bugs',
style: TextStyle(
color: _isItemSelected
? Colors.orangeAccent
: Colors.blueGrey,
),
)),
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
_isItemSelected = !_isItemSelected;
});
},
child: Container(
height: 35,
margin: EdgeInsets.symmetric(horizontal: 5, vertical: 5),
decoration: BoxDecoration(
color:
!_isItemSelected ? Colors.white : Colors.transparent,
borderRadius: BorderRadius.circular(5),
boxShadow: !_isItemSelected
? [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset:
Offset(0, 3), // changes position of shadow
),
]
: null,
),
child: Center(
child: Text(
"Improvements",
style: TextStyle(
color: !_isItemSelected
? Colors.orangeAccent
: Colors.blueGrey,
),
)),
),
),
),
],
),
)
],
));
}
}
让我知道它是否有效。
推荐阅读
- java - 如何解决多语言应用程序在方向更改时自动更改语言的问题?
- c# - 在 Select LINQ 中错过 null 值的最佳方法
- python - Python 2 和 3 csv 模块文本二进制模式向后兼容
- python - PyQt:如何在两个按钮之间创建一个 lineItem 并可以随按钮移动?
- selenium - Selenium reactjs 启用 javascript 问题
- google-bigquery - 使用 Google BigQuery 从 JSON 中的多个属性值中提取值
- proxy - “无法握手”:执行 sudo apt-get update 时出错
- c# - 使用多个数据类型为键反序列化 JSON 文件
- datalog - 防止数据记录逻辑中的对称对
- android - 如何更改特定的(具有特殊价值的)RecyclerView 的 imageview 显示