Я создал макет (код ниже), но я столкнулся с 2 проблемами с ним.
![enter image description here](https://i.stack.imgur.com/kOOCI.png)
Issue 1:
текст в bottomRightSection переполняется снаружи экран вместо перехода на следующую строку.
Я пытался поместить его в виджеты обертки и контейнера, и я также пытался добавить атрибут max lines, но он все еще переполняется снаружи.
Issue 2:
в topRightSection, я хочу чтобы переместить кнопки «Текст» и «Значок» в конец экрана вправо.
Когда я добавляю Spacer () между ними или оборачиваю их в Expanded / Flexible, они исчезают.
Буду признателен за ваше время и поддержку
import 'package:flutter/material.dart';
class ProductItemUi extends StatefulWidget {
@override
_ProductItemUiState createState() => _ProductItemUiState();
}
class _ProductItemUiState extends State<ProductItemUi> {
@override
Widget build(BuildContext context) {
Widget leftSection() {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'New',
style: TextStyle(
color: Colors.red,
fontSize: 18.0,
fontWeight: FontWeight.w400,
),
),
SizedBox(
height: 10.0,
),
CircleAvatar(
backgroundColor: Colors.grey,
radius: 25.0,
),
],
);
}
Widget topRightSection() {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Product Name',
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
),
),
Text(
'Product Price',
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
),
),
],
),
//Spacer(),
FlatButton(
onPressed: () {},
child: Text(
'Cart',
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
),
),
),
IconButton(
onPressed: () {},
icon: Icon(
Icons.more_vert,
color: Colors.black,
),
)
],
);
}
Widget bottomRightSection() {
return Container(
color: Colors.grey[300],
height: 50.0,
child: Text(
'This text will be a long description about the product. Lorem ipsum dolor sit amet, consectetur adipis elit.',
maxLines: 2,
overflow: TextOverflow.fade,
softWrap: false,
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
),
),
);
}
return Scaffold(
backgroundColor: Colors.black,
body: Container(
margin: EdgeInsets.only(top: 100.0),
width: MediaQuery.of(context).size.width,
height: 100.0,
color: Colors.white,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
leftSection(),
SizedBox(
width: 5.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
topRightSection(),
bottomRightSection(),
],
),
],
),
),
);
}
}