如何改变图像颜色?
原始图像:
预计 :
代码 :
Center(
child: Container(
height: 181.0,
width: MediaQuery.of(context).size.width - 46.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFB3E2D6),
Color(0xFF18A2A5).withOpacity(0.5),
],
),
),
child: Stack(
children: [
Positioned(
right: -20,
bottom: 0,
top: 0,
child: Image.asset(
'assets/images/border_background.png',
width: 220,
height: 220,
fit: BoxFit.cover,
),
),
Positioned(
right: -5,
bottom: 0,
top: 0,
child: Image.asset(
'assets/images/lisa-removebg-preview.png',
height: 151,
width: 207,
fit: BoxFit.cover,
color: Color(0xFF7CD2CC), colorBlendMode: BlendMode.modulate,
),
)
],
),
),
), …Run Code Online (Sandbox Code Playgroud) 我尝试使用 Slider().. 划分看起来不错(值 >= 50 ? 10 : 20)
但是,如何在滑块上方添加刻度和标签?
预计 :
勾选将根据滑块位置改变颜色
实际的:
Slider(
min: 0,
max: 100,
value: value,
onChanged: (val) {
setState(() {
value = val;
});
},
divisions: value >= 50 ? 10 : 20,
label: value.toString(),
),
Run Code Online (Sandbox Code Playgroud)
我的问题是:
我的代码使用 Column(
Column(
children: [
Container(
margin: EdgeInsets.symmetric(horizontal: 20),
child:
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(6, (index) => Text('$index')),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(
16,
(index) => SizedBox(
height: 8,
child: VerticalDivider( …Run Code Online (Sandbox Code Playgroud) 我尝试创建一个这样的轮廓模型;fromJson看起来不错,但我有一个问题toJson:
@Freezed(
fromJson: true,
toJson: true,
map: FreezedMapOptions.none,
when: FreezedWhenOptions.none,
)
class ProfileAttribute with _$ProfileAttribute {
const factory ProfileAttribute({
@JsonKey(name: '_id', includeIfNull: false) final String? id,
final String? uid,
final String? username,
final String? name,
final String? phone,
final String? email,
final String? address,
final String? image,
}) = _ProfileAttribute;
factory ProfileAttribute.fromJson(Map<String, dynamic> json) =>
_$ProfileAttributeFromJson(json);
}
Run Code Online (Sandbox Code Playgroud)
我看到调试 toJson 将发送:
"attributes": {
"_id": null,
"uid": null,
"username": null,
"name": null,
"phone": null,
"email": "asdasda@gmasd.com",
"address": null, …Run Code Online (Sandbox Code Playgroud) flutter flutter-dependencies json-serializable flutter-freezed
如何在未TextInputLayout聚焦时更改边框和颜色?
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_height="wrap_content"
app:boxStrokeWidth="4dp"
app:boxStrokeColor="@color/colorPrimary"
app:layout_constraintTop_toBottomOf="@id/a">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:hint="@string/app_name"
android:textColorHint="@color/colorPrimary"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我尝试:
app:boxStrokeWidth="4dp"
app:boxStrokeColor="@color/colorPrimary"
Run Code Online (Sandbox Code Playgroud)
但是,不能在不聚焦的情况下工作
android android-xml android-textinputlayout material-components material-components-android