import 'package:flutter/material.dart';
import 'package:krishi/appinfo.dart';
import 'package:krishi/homescreen.dart';
import 'package:krishi/catalog.dart';
class Cassava extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(60),
child:AppBar(
elevation: 0,
backgroundColor: Colors.green,
title: Center(
child: Text('More info',
style: TextStyle(
color: Colors.white,
fontFamily: 'Montserrat',
fontSize: 18,
fontWeight: FontWeight.w800,
),
),
),
actions: <Widget>[
PopupMenuButton(
onSelected: (value) {
switch (value) {
case '1': Navigator.push(context, MaterialPageRoute(builder: (context) => Catalog()));
break;
case '2': Navigator.push(context, MaterialPageRoute(builder: (context) => AppInfo()));
break;
default:
}
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
elevation: 3.0,
offset: Offset(10, 40),
tooltip: 'More options',
icon: Icon(Icons.more_vert, color: Colors.white),
itemBuilder: (BuildContext context) =>
<PopupMenuEntry>[
PopupMenuItem(
value: '1',
child: Text('Catalog')),
PopupMenuItem(
value: '2',
child: Text('App info')),
// PopupMenuItem(
// value: '3',
// child: Text('Check for updates'))
],
),
],
),
),
body: CassavaContainer(),
bottomNavigationBar: BottomNavigationBar(
onTap: (index) {
switch (index) {
case 0: Navigator.push(context, MaterialPageRoute(builder: (context) => Home()));
break;
case 1: Navigator.push(context, MaterialPageRoute(builder: (context) => Catalog()));
break;
case 2: Navigator.push(context, MaterialPageRoute(builder: (context) => AppInfo()));
break;
default:
}
},
currentIndex: 1,
selectedItemColor: Colors.green,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home, color: Colors.green),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.list, color: Colors.green),
title: Text('Catalog'),
),
BottomNavigationBarItem(
icon: Icon(Icons.info, color: Colors.green),
title: Text('App info'),
),
],
),
);
}
}
class CassavaContainer extends StatefulWidget {
@override
_CassavaContainerState createState() => _CassavaContainerState();
}
class _CassavaContainerState extends State<CassavaContainer> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget> [
Expanded(
flex: 4,
child: Container(
margin: EdgeInsets.fromLTRB(12, 12, 12, 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15),
topRight: Radius.circular(15),
bottomLeft: Radius.circular(15),
bottomRight: Radius.circular(15),
),
boxShadow: [
BoxShadow(
color: Colors.blueGrey[200],
offset: Offset(3, 3),
blurRadius: 8.0,
),
],
color: Colors.white,
),
child: Row(
children: <Widget>[
Expanded(
flex: 2,
child:Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15),
bottomLeft: Radius.circular(15),
),
image: DecorationImage(
image: AssetImage("assets/cassava_cover.jpg"),
fit: BoxFit.cover,
),
),
),
),
Expanded(
flex: 2,
child:Column(
children: <Widget>[
Expanded(
flex: 2,
child: Container(
// color: Colors.red,
alignment: Alignment.center,
child: Text('Cassava',
style: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
),
Expanded(
flex: 2,
child: Container(
// color: Colors.green,
child: Row(
children: <Widget> [
Expanded(
flex: 2,
child: Container(
// color: Colors.amber,
child: Icon(Icons.ac_unit,),
),
),
Expanded(
flex: 6,
child: Container(
padding: EdgeInsets.only(
left: 8,
),
alignment: Alignment.centerLeft,
child: Text('25\u00b0C to 29\u00b0C',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 16,
// color: Colors.white,
),
),
),
),
],
),
),
),
Expanded(
flex: 2,
child: Container(
// color: Colors.green,
child: Row(
children: <Widget> [
Expanded(
flex: 2,
child: Container(
child: Icon(Icons.brightness_5,),
)
),
Expanded(
flex: 6,
child: Container(
padding: EdgeInsets.only(
left: 8,
),
child: Text('Natural light',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 16,
// color: Colors.white,
),
),
)
),
]
),
),
),
Expanded(
flex: 2,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(15),
),
// color: Colors.green,
),
child: Row(
children: <Widget> [
Expanded(
flex: 2,
child: Container(
child: Icon(Icons.grain,),
),
),
Expanded(
flex: 6,
child: Container(
padding: EdgeInsets.only(
left: 8,
),
child: Text('Red lateritic loam',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 16,
// color: Colors.white,
),
),
),
),
]
),
),
),
],
),
),
],
),
),
),
Expanded(
flex: 6,
child: Container(
margin: EdgeInsets.fromLTRB(12, 12, 12, 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.blueGrey[200],
offset: Offset(3, 3),
blurRadius: 8.0,
),
],
),
// Check the below code. I think that's the error. But I don't know how to solve it
child: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: ListView(
shrinkWrap: true,
children: <Widget> [
Expanded(
child: Container(
height: 60,
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(
left: 12,
),
错误:ParentDataWidget Expanded(flex:1)希望将FlexParentData类型的ParentData应用于RenderObject,该对象已设置为接受不兼容类型ParentData的ParentData。 通常,这意味着Expanded小部件的祖先RenderObjectWidget错误。通常,扩展小部件直接放置在Flex小部件内部。 令人反感的Expanded当前位于RepaintBoundary小部件内。
我认为这是因为我使用ListView()作为Expanded()的父窗口小部件。但是我不知道该怎么解决。