Flutter 无状态窗口小部件列固定白色
即使我给它一个背景色,它仍然是白色的。它以前工作得很好,但它只是不可修复的Flutter 无状态窗口小部件列固定白色,flutter,dart,Flutter,Dart,即使我给它一个背景色,它仍然是白色的。它以前工作得很好,但它只是不可修复的 在删除代码之前 删除代码后 使用容器()小部件包装列,并将所需颜色传递给颜色:属性。如果Material()小部件中的颜色:不起作用 PS:这应该也适用于StatelefulWidgets 像这样: child: Material( //color: Colors.lightBlueAccent, // for me this was working. child:
在删除代码之前
删除代码后
使用
容器()小部件包装列,并将所需颜色传递给颜色:
属性。如果Material()
小部件中的颜色:
不起作用
PS:这应该也适用于StatelefulWidgets
像这样:
child: Material(
//color: Colors.lightBlueAccent, // for me this was working.
child: Container(
// Its important to wrap a ListTile with a sized widget
height: 300.0,
width: MediaQuery.of(context).size.width,
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
subtitle: Text(
'This is working',
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
{
return Scaffold(
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.amber,
child: Center(
child: Material(
//color: Colors.lightBlueAccent, // for me this was working.
child: Container(
// Its important to wrap a ListTile with a sized widget
height: 300.0,
width: MediaQuery.of(context).size.width,
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
subtitle: Text(
'This is working',
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
),
),
);
}
}
}
子项:材质(
//color:Colors.lightBlueAccent,//对我来说这很有效。
子:容器(
//用一个大小合适的小部件包装ListTile很重要
高度:300.0,
宽度:MediaQuery.of(context).size.width,
颜色:颜色。蓝灰色,
子:列(
mainAxisAlignment:mainAxisAlignment.space,
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
列表砖(
标题:Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
字幕:文本(
“这起作用了”,
样式:TextStyle(颜色:Colors.white),
),
),
],
),
),
),
输出:
child: Material(
//color: Colors.lightBlueAccent, // for me this was working.
child: Container(
// Its important to wrap a ListTile with a sized widget
height: 300.0,
width: MediaQuery.of(context).size.width,
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
subtitle: Text(
'This is working',
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
{
return Scaffold(
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.amber,
child: Center(
child: Material(
//color: Colors.lightBlueAccent, // for me this was working.
child: Container(
// Its important to wrap a ListTile with a sized widget
height: 300.0,
width: MediaQuery.of(context).size.width,
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
subtitle: Text(
'This is working',
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
),
),
);
}
}
}
整个代码:
child: Material(
//color: Colors.lightBlueAccent, // for me this was working.
child: Container(
// Its important to wrap a ListTile with a sized widget
height: 300.0,
width: MediaQuery.of(context).size.width,
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
subtitle: Text(
'This is working',
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
{
return Scaffold(
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.amber,
child: Center(
child: Material(
//color: Colors.lightBlueAccent, // for me this was working.
child: Container(
// Its important to wrap a ListTile with a sized widget
height: 300.0,
width: MediaQuery.of(context).size.width,
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
subtitle: Text(
'This is working',
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
),
),
);
}
}
}
导入“包装:颤振/材料.省道”;
void main(){
runApp(MyApp());
}
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“颤振演示”,
主题:主题数据(
主样本:颜色。蓝色,
视觉密度:视觉密度。自适应平台密度,
),
主页:MyHomePage(标题:“颤振演示主页”),
);
}
}
类MyHomePage扩展了无状态小部件{
MyHomePage({Key,this.title}):超级(Key:Key);
最后的字符串标题;
@凌驾
小部件构建(构建上下文){
{
返回脚手架(
主体:容器(
宽度:MediaQuery.of(context).size.width,
高度:MediaQuery.of(context).size.height,
颜色:颜色。琥珀色,
儿童:中心(
儿童:材料(
//color:Colors.lightBlueAccent,//对我来说这很有效。
子:容器(
//用一个大小合适的小部件包装ListTile很重要
高度:300.0,
宽度:MediaQuery.of(context).size.width,
颜色:颜色。蓝灰色,
子:列(
mainAxisAlignment:mainAxisAlignment.space,
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
列表砖(
标题:Image.network('https://telegra.ph/file/fcae4efdaeb34e640ef1f.png'),
字幕:文本(
“这起作用了”,
样式:TextStyle(颜色:Colors.white),
),
),
],
),
),
),
),
),
);
}
}
}
始终在您的问题中添加一些代码,这些代码是您为解决所面临的问题而尝试过的,或者是当前的代码