मेरे पास एक टेक्स्ट टेक्स्ट तत्व है जो एक स्टैक में छवि तत्व के शीर्ष पर बैठता है। मैं, कि पाठ तत्व के लिए एक सरल पृष्ठभूमि रंग लागू करना चाहते हैं, ताकि वह एक शीर्षक बॉक्स की तरह पाठ फ्रेम:टेक्स्ट के एक निर्धारित ब्लॉक के लिए मैं पृष्ठभूमि रंग कैसे प्रारूपित करूं?
मुझे लगता है कि ढेर में एक और तैनात बच्चे के रूप में एक कंटेनर डालने से यह कर सकते हैं । लेकिन पाठ स्ट्रिंग में हर बार चौड़ाई को फिर से समझना होगा, जो उप-इष्टतम है। क्या कोई बेहतर तरीका है?
var stack = new Stack(
children: <Widget>[
new Image.asset (// background photo
"assets/texture.jpg",
fit: ImageFit.cover,
height: 600.0,
),
new Positioned (// headline
child: new Container(
decoration: new BoxDecoration (
backgroundColor: Colors.black
),
),
left: 0.0,
bottom: 108.0,
width: 490.0,
height: 80.0,
),
new Positioned (
child: new Text (
"Lorem ipsum dolor.",
style: new TextStyle(
color: Colors.blue[500],
fontSize: 42.0,
fontWeight: FontWeight.w900
)
),
left: 16.0,
bottom: 128.0,
)
]
);