问题
How could I achieve this layout in Flutter?
回答1:
I published package drop_cap_text to achive DropCapText, you can also put an image as custom widget inside DropCap.
回答2:
its Pretty basic just simple Row with the data inside it
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Image.asset('Your image link here'),
Text('you paragraph here')
],)
回答3:
You can use Stack(): https://flutter.io/docs/development/ui/layout#stack
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
var stack = Stack(
alignment: const Alignment(0.6, 0.6),
children: [
CircleAvatar(
backgroundImage: AssetImage('images/pic.jpg'),
radius: 100.0,
),
Container(
decoration: BoxDecoration(
color: Colors.black45,
),
child: Text(
'Mia B',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
],
);
// ...
}
}
You can use a Container() widget with foregroundDecoration:
Container(
child: Text('Hello World'),
foregroundDecoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('https://www.example.com/images/frame.png'),
centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
),
),
来源:https://stackoverflow.com/questions/54129884/how-can-i-float-text-around-an-image-in-flutter