Flutter solves the problem of incorrect use of parent datawidget and boundary constraint
The error information is as follows:
What about this kind of error
1 tells us that this error is related to the parent component, and then we can see 2 errors, and we can analyze the column – & gt under the page when loading the homepage written by ourselves; Container-> ConstrainedBox-> Expanded-> There is a problem with the subcomponents in the path of constrainedbox
the solution is to remove the expanded control and directly use it in constrainedbox
original code:
Container(
// width: MediaQuery.of(context).size.width,
height: 36.0,
child: Expanded(
flex: 1,
child: ConstrainedBox(
constraints: BoxConstraints.expand(),
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: [
Positioned(
child: Text("Recommendation",textDirection: TextDirection.ltr,style: TextStyle(fontSize: 20),),
left: 3.0,
top: 3.0,
),
Positioned(
right: 3.0,
top: 3.0,
child: Container(
child: Text("More",textDirection: TextDirection.rtl,style: TextStyle(fontSize: 16),),
/*Padding(
padding: EdgeInsets.all(4),
child:
),*/
decoration: BoxDecoration(
border: Border.all(color: Colors.black87,width: 1.0,style: BorderStyle.solid),
borderRadius: BorderRadius.circular(20)
),
)
)
],
),
),
),
)
Modified code:
Container(
// width: MediaQuery.of(context).size.width,
height: 36.0,
child: ConstrainedBox(
constraints: BoxConstraints.expand(),
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: [
Positioned(
child: Text("Recommendation",textDirection: TextDirection.ltr,style: TextStyle(fontSize: 20),),
left: 3.0,
top: 3.0,
),
Positioned(
right: 3.0,
top: 3.0,
child: Container(
child: Text("More",textDirection: TextDirection.rtl,style: TextStyle(fontSize: 16),),
/*Padding(
padding: EdgeInsets.all(4),
child:
),*/
decoration: BoxDecoration(
border: Border.all(color: Colors.black87,width: 1.0,style: BorderStyle.solid),
borderRadius: BorderRadius.circular(20)
),
)
)
],
),
)
)
Why is this right
after a variety of baidu searches, it is found that the widget in flutter is rendered by the renderbox object at its bottom. The render box is constrained by its parent widget, and its size is adjusted according to these constraints. Constraints are composed of minimum width, maximum width, minimum height and maximum height; The size is composed of specific width and height
Read More:
- CentOS solves the problem of modulenotfounderror when salt calls python3 script remotely, and solves the problem that PIP3 module cannot be shared by different users
- MYSQL ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
- Centos7 solves the problem of unable to use tab to complete automatically
- Android solves the gliding problem of EditText
- Mysql error when deleting the table structure: Error Code: 1217. Cannot delete or update a parent row: a foreign key constraint fails
- 1822 – Failed to add the foreign key constraint. Missing index for constraint ‘tb_emp_ibfk_1’ in the
- Failed to add the foreign key constraint. Missing index for constraint ‘stu_ibfk_1’ in the reference
- Windows subsystem Ubuntu 18.04 solves SSH problem
- Solve the problem of permission after flutter package_ Handler failure
- IOS solves the problem of this action could not be completed. Try again
- Vs code solves the problem that latex does not display references and [?] is displayed in the text
- Unity Android solves the problem of information flow advertisement closing and error reporting
- Jsonformat annotation solves the problem of time format in the front end of localdatetime
- Centos8 solves the problem of “failed to set locale, defaulting to c.utf-8”
- Git solves the problem of failed: http request failed
- The background object of thymeleaf is null, which solves the problem of error when the object is empty to get the property value
- Selenium reports an error and solves the problem of element not interactive exception, element not interactive
- FTP use get command 550 failed to open file, but use the put command to solve the problem
- [building the flutter environment] error: the flutter directory is not a clone of the GitHub project
- Node-error cause analysis: Error: Multipart: Boundary not found