【发布时间】:2020-08-02 00:17:26
【问题描述】:
我只是想改变这个 Flutter 应用程序的背景颜色。
请告诉我如何添加图片作为背景。 以及如何更改该图像的不透明度?
import 'package:flutter/material.dart';
void main() => runApp(Loginscreen());
class Loginscreen extends StatelessWidget {
static const routeName = '/login';
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
//title: Text('LOG IN'),
elevation: 0,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: () {},
),
),
body: Container(
padding: const EdgeInsets.all(15),
color: Theme.of(context).primaryColor,
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
TextField(
style: TextStyle(fontSize: 18, color: Colors.black54),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: 'User Name',
contentPadding: const EdgeInsets.all(15),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(5),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(5),
),
),
),
SizedBox(
height: 20,
),
TextField(
obscureText: true,
style: TextStyle(fontSize: 18, color: Colors.black54),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: 'Password',
contentPadding: const EdgeInsets.all(15),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(5),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(5),
),
),
),
SizedBox(
height: 20,
),
FlatButton(
onPressed: null,
child: Text(
'Log In',
style: TextStyle(
fontSize: 20,
),
),
shape: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(5),
),
padding: const EdgeInsets.all(15),
textColor: Colors.white,
),
],
)),
),
);
}
}
【问题讨论】:
-
我的解决方案对你有用吗?