android - 使用 Cupertino 分段控制在第一页正文中打开第二页
问题描述
我正在使用 Cupertino Segmente Control ,我使用三个摆动创建了一个选项卡,并将三个小部件分配给首页正文。选择任何选项卡时,它会显示新小部件的正文。到目前为止,一切正常。产品加载在每个页面内,当我们选择产品时,它必须转到第二页。第二页打开,但在第一页的正文中。如果你帮助我,非常感谢你
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int groohEntkhabi = 1;
final Map<int, Widget> logoBala = const <int, Widget>{
0: Text("کشاورزی" ,style: TextStyle(fontSize: 14),),
1: Text("خرید فروش" ,style: TextStyle(fontSize: 14),),
2: Text("رهن و اجاره" ,style: TextStyle(fontSize: 14),),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.blue),
//centerTitle: true,
title: Container(
child: Row(
children: [
Expanded(
child: CupertinoSegmentedControl(
padding: EdgeInsets.all(0.0),
groupValue: groohEntkhabi,
onValueChanged: (changeFromGroupValue) {
setState(() {
groohEntkhabi = changeFromGroupValue;
});
},
children: logoBala,
),
),
],
)
),
actions: [
IconButton(icon: Icon(Icons.search), onPressed: (){}),
],
),
drawer: MyDraver(),
bottomNavigationBar: MyBottomNavigation(),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {}, label: Text("ثبت رایگان آگهی",style: TextStyle(color: Colors.white),), icon:Icon(Icons.add,color: Colors.white,),backgroundColor: Colors.blue,
),
// floatingActionButton: FloatingActionButton(onPressed: (){
// // Navigator.of(context).push(MaterialPageRoute(
// // builder: (context) => Shoab()
// // ));
// },
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
// backgroundColor: Colors.deepOrange,
// child:Center(child: Text("ثبت رایگان آگهی")),),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body:
(
_childern(groohEntkhabi)
),
),
);
}
Widget _childern(index){
List<Widget> page_screen=[];
page_screen.add(_keshavarzi());
page_screen.add(kharidFroosh());
page_screen.add(_ejare());
return page_screen[index];
}
Widget kharidFroosh(){
return MaterialApp(
debugShowCheckedModeBanner: false,
localizationsDelegates: [
// ... app-specific localization delegate[s] here
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en', ''), // farsi
],
home: ListView.builder(padding: EdgeInsets.only(top: 3.0,left: 3.0,right: 3.0),
itemBuilder: mycard_view1,itemCount: 5,));
}
Widget mycard_view1(BuildContext context ,int index){
String mogheiatt ="کوی ملا نفس";
String mogheiat = mogheiatt.length>14 ? mogheiatt.substring(0,14):mogheiatt;
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),),
elevation: 1.0,
//color: Colors.blue,
child: InkWell(
onTap: (){
Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => Safhe2_kharid_froosh()));
},
child: Stack(
children: <Widget> [
Container(margin: EdgeInsets.fromLTRB(50.0, 5.0, 5.0, 5.5),
height: 160.0,
width: double.infinity,
decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(20.0)),
child: Padding(
padding: EdgeInsets.fromLTRB(100.0,10.0,10.0,2.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text("فروش ویلایی",style: TextStyle(fontFamily: "shabnammedium",fontSize: 15.0),),
SizedBox(
height: 7.0,
),
Text("قیمت : 850 م تومان",style: TextStyle(fontFamily: "shabnammedium",fontSize: 15.0),),
SizedBox(
height: 7.0,
),
Text("متراژ : 85 متر ",style: TextStyle(fontFamily: "shabnammedium",fontSize: 15.0),),
SizedBox(
height: 30.0,
),
Row(
//crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
decoration: BoxDecoration(color: Color(0xffe1f5fe),borderRadius: BorderRadius.circular(10.0),),
child: Center(child: Padding(
padding: EdgeInsets.only(left: 3.0,right: 3.0),
child: Row(
children: [
Text("روز پیش",style: TextStyle(fontFamily: "shabnamlight",color: Colors.black87),),
Text("5",style: TextStyle(fontFamily: "shabnamlight",color: Colors.black87),),
],
),
)),
// width: 70.0,
),
Container(
child: Row(
children: [
Text("...",style: TextStyle(fontFamily: "shabnamlight",color: Colors.black87),),
Text(mogheiat,style: TextStyle(fontFamily: "shabnamlight",color: Colors.black87),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
//width: 100.0,
),
],
),
],
),
),
),
Positioned(
left: 10.0,
top: 5.0,
bottom: 5.0,
child: ClipRRect(borderRadius: BorderRadius.circular(15.0),
child:Image.asset("images/home.jpg",width: 130,fit: BoxFit.cover,),
),
),
],
),
),
);
}
Widget _keshavarzi(){
return Keshavarzi();
}
Widget _ejare(){
return Ejare();
}
}
这是我的图片应用
解决方案
推荐阅读
- python - 使用 dtype 将数据帧从 float64 转换为对象
- c - C语言我不懂素数排序代码
- angular - 从 Typescript 中的 JSON 响应对象中获取单独的标题行和数据行
- python - 使用 PyECG 包读取 .ecg 文件时的错误消息
- oracle - Oracle sql loader 加载带有标识列的表的时间过长
- python - “return False”完全忽略?
- python - 使用 tf.keras.estimator.model_to_estimator 将 keras 模型转换为估计器模型后使用 estimator.train() 的问题
- rust - 如何在 Gtk-rs 中获取选定列的文本
- python - 带有 Selenium 的 FileNotFoundError (Python 3.8)
- c# - MS Graph:Azure AD - 如何在用户列表中找到源列?