当前位置: 首页 > news >正文

没网站怎么做京东联盟无备案网站加速

没网站怎么做京东联盟,无备案网站加速,百度网站的域名是什么,网站建设设计风格如何与色彩搭配Flutter 的导航页面跳转#xff0c;是通过组件Navigator 和 组件MaterialPageRoute来实现的#xff0c;Navigator提供了很多个方法#xff0c;但是目前#xff0c;我只记录我学习过程中接触到的方法#xff1a; Navigator.push(), 跳转下一个页面Navigator.pop(), 返回上一…Flutter 的导航页面跳转是通过组件Navigator 和 组件MaterialPageRoute来实现的Navigator提供了很多个方法但是目前我只记录我学习过程中接触到的方法 Navigator.push(), 跳转下一个页面Navigator.pop(), 返回上一个页面 1. 不带参数的页面跳转案例 代码如下 import package:flutter/material.dart;void main() {runApp(MaterialApp(title: 导航演示,home: FirstScreen(),)); }class FirstScreen extends StatelessWidget {overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text(导航页面),),body: Center(child: ElevatedButton(style: ElevatedButton.styleFrom(backgroundColor: Colors.blueAccent,foregroundColor: Colors.white),onPressed: (){Navigator.push(context, MaterialPageRoute(builder: (context) SecondScreen()));}, child: Text(查看商品详情页))),);} }class SecondScreen extends StatelessWidget {overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text(商品详情页)),body: Center(child: ElevatedButton(onPressed: (){Navigator.pop(context);}, child: Text(点击返回)),),);} }效果图 2. 导航常数的传递和接收 代码如下 import package:flutter/material.dart;void main() {runApp(MaterialApp(title: 导航演示,home: ProductList(products: List.generate(20, (i) Product(商品$i, 这是一个商品详情页编号为:$i))))); }class ProductList extends StatelessWidget {// 定义一个参数final ListProduct products;// 接收参数const ProductList({super.key, required this.products});overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar( title: Text(商品列表)),body: ListView.builder(itemCount: products.length,itemBuilder: (context, index) {return ListTile(title: Text(products[index].title),onTap: (){Navigator.push(context, MaterialPageRoute(builder: (context) ProductDetail(product:products[index])));},);}));} }// 商品详情页 class ProductDetail extends StatelessWidget {// 定义一个参数final Product product;const ProductDetail({super.key, required this.product});overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text(product.title)),body: Center(child: Text(product.description),),);} }// 定义一个商品的对象 class Product {final String title; // 商品标题final String description; // 商品描述Product(this.title, this.description); }效果图如下 3. 子页面给父级页面返回数据 代码如下 import package:flutter/material.dart;void main() {runApp(MaterialApp(title: 导航演示,home: FirstPage())); }class FirstPage extends StatelessWidget {const FirstPage({super.key});overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text(子页面将数据回传给父视图)),body: Center(child: RouteButton(),),);} }class RouteButton extends StatelessWidget {overrideWidget build(BuildContext context) {return ElevatedButton(onPressed: (){_navigateDataToChildView(context);}, child: Text(传递数据));}_navigateDataToChildView(BuildContext context) async {// 等待子视图返回时回传的数据final result await Navigator.push(context, MaterialPageRoute(builder: (context) ChildView()));// 屏幕底部的小弹窗ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(result)));} }// 子视图 class ChildView extends StatelessWidget {const ChildView({super.key});overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text(子视图)),body: Center(child: Column(children: [ElevatedButton(onPressed: (){Navigator.pop(context, 回传这是第一个数据回传);}, style: ElevatedButton.styleFrom(backgroundColor: Colors.blueAccent,foregroundColor: Colors.white),child: Text(第一个数据回传)),ElevatedButton(onPressed: (){Navigator.pop(context, 回传这是第二个数据回传);},style: ElevatedButton.styleFrom(backgroundColor: Colors.orangeAccent,foregroundColor: Colors.white), child: Text(第二个数据回传))],),),);} }效果图如下 Flutter_学习记录_数据回传 4. 设置导航栏的主题色 MaterialApp组件里面有个 theme属性设置theme属性就可以设置导航栏的主题色代码如下 import package:flutter/material.dart;void main() {runApp(MyApp()); }class MyApp extends StatelessWidget {const MyApp({super.key});overrideWidget build(BuildContext context) {return MaterialApp(debugShowCheckedModeBanner: true,home: Contrainer(),// 设置导航栏的主题色theme: ThemeData(appBarTheme: AppBarTheme(backgroundColor: Colors.yellow, // 设置导航栏颜色为蓝色),),);} }5. 导航栏的左右两侧添加操作按钮 AppBar组件中的leading是可以添加左边一个按钮actions是可以添加右边的一组按钮代码实例如下 import package:flutter/material.dart;void main() {runApp(MyApp()); }class MyApp extends StatelessWidget {const MyApp({super.key});overrideWidget build(BuildContext context) {return MaterialApp(debugShowCheckedModeBanner: true,home: Home(),theme: ThemeData(appBarTheme: AppBarTheme(backgroundColor: Colors.yellow, // 设置导航栏颜色为蓝色),),);} }class Home extends StatelessWidget {const Home({super.key});overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(// 添加左边的操作按钮leading: IconButton(onPressed: () debugPrint(navigation button is pressed.), icon: Icon(Icons.menu),tooltip: Navigation,),// 添加右边的操作按钮actions: [IconButton(onPressed: () debugPrint(navigation button is pressed.), icon: Icon(Icons.search),tooltip: search,)],title: Text(App Demo),elevation: 0.0),body: Center(child: Text(添加导航栏的事件),),);} } 效果图如下
http://www.w-s-a.com/news/878959/

相关文章:

  • wordpress设置密码访问带提示广州做网站优化哪家专业
  • 如何帮人做网站赚钱西安室内设计公司排名
  • 房产网站建设产品网站域名和邮箱域名
  • 网站建设核心优势seo求职信息
  • 网站手册自己在百度上可以做网站吗
  • 影楼网站源码建行业网站的必要性
  • 深圳app网站设计软件开发公司税收优惠政策
  • 北京市中关村有哪家可以做网站维护客户管理系统 wordpress
  • 做网站拉客户有效吗全景图网页制作工具
  • 网站建设公司行业建设网站需要提供什么资料
  • 别人的做网站网页打不开图片
  • 北京专业网站设计推荐怎么建立网站网址
  • 上海网站建设开发公司哪家好网站数据搬家
  • 杭州建站平台哪里有免费的网站推广软件
  • 深圳极速网站建设服务什么网站可以做产品入驻
  • 淄博易宝网站建设app推广拉新公司
  • 营销型外贸网站建设软件备案域名出租
  • 网站域名禁止续费m99ww094cn 苍井空做的网站
  • 上海建设工程网站大同网站建设熊掌号
  • 设计类书籍网站江苏网站建设简介模板
  • 手机企业网站推广c 手机app开发
  • 网站建设需要多少天凡客建设网站稳定吗
  • 房天下网站建设女生说wap是什么意思
  • 网站开发安全机制北京做网站多少钱合理
  • 扁平化 公司网站建设大型视频网站需要的资金量
  • 免费建各种网站淄博网站建设yx718
  • 凡科网建站入门教程运城市网站建设
  • 黄浦区未成年人思想道德建设网站oa系统是什么
  • 微信里的网站怎么做电子商务网站开发平台
  • 易企秀网站怎么做轮播图网站建设张世勇