新建一个页面FirstScreen.dart
main.dart改动代码

导入
import 'dart:ui' as ui;
import 'package:flutter_module/FirstScreen.dart';
1
2
修改
//void main() => runApp(MyApp());
void main() => runApp(_widgetForRoute(ui.window.defaultRouteName));

Widget _widgetForRoute(String route) {
switch (route) {
case 'myApp':
return MyApp();
default:
return MaterialApp(
home: Center(
child: Text('没找到'),
),
);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
增加一个函数跳转:FirstScreen.dart

class _MyHomePageState extends State<MyHomePage> {
......
Future<void> _goOCPage(BuildContext context) async {
print('我要去Flutter 的下一个页面了');
Navigator.push(context, MaterialPageRoute(builder: (context){
return new FirstScreen();
}));
}
......
}
1
2
3
4
5
6
7
8
9
10
在body的{} 中添加一个文本和按钮FlatButton用于跳转到FirstScreen.dart

Text(
'自我介绍,我是flutter页面',
),

FlatButton(
child: Text("去下一个Flutter页面"),
textColor: Colors.blue,
onPressed: (){
_goOCPage(context);
},
),
1
2
3
4
5
6
7
8
9
10
11
FirstScreen.dart 的全部代码

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:async';

class FirstScreen extends StatelessWidget {
static const platform = const MethodChannel('samples.flutter.dev/battery');

Future<void> _goOCPage() async {
print('我要去OC 页面了');
String batteryLevel;
try {
final int result = await platform.invokeMethod('getBatteryLevel');
batteryLevel = 'Battery level at $result % .';
} on PlatformException catch (e) {
batteryLevel = "Failed to get battery level: '${e.message}'.";
}

print('调用了$batteryLevel');
}

Future<void> _goSomePage() async {
print('我要去导航的指定页面了');
String batteryLevel;
try {
final int result = await platform.invokeMethod('backToNavigatorIndex',[1]);
batteryLevel = 'backSmoePahe $result % .';
} on PlatformException catch (e) {
batteryLevel = "Failed to backSmoePahe: '${e.message}'.";
}

print('back$batteryLevel');
}

@override
Widget build(BuildContext context) {

Future<dynamic> _handler(MethodCall methodCall) {
if ("passArgusToFlutter" == methodCall.method) {
print('methodCall-arguments:${methodCall.arguments}');
}
return Future.value(123);
}
platform..setMethodCallHandler(_handler);

return Scaffold(
appBar: AppBar(
title: Text('FirstScreen 页面'),
),
body: Center(
child: Column(

mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'自我介绍,我是flutter页面',
),

FlatButton(
child: Text("backLastPage"),
textColor: Colors.blue,
onPressed: (){
Navigator.pop(context);
},
),

FlatButton(
child: Text("goOCPage"),
textColor: Colors.blue,
onPressed: (){
_goOCPage();
},
),

FlatButton(
child: Text("backToSomePage"),
textColor: Colors.blue,
onPressed: (http://www.amjmh.com/v/BIBRGZ_558768/){
_goSomePage();
},
),

],
),
),
);
}
}
---------------------

Flutter端代码的更多相关文章

  1. web端代码提示

    web端代码提示 这个功能是基本完成了,但是与需求不一致.但是废弃挺可惜的,所以就单独拿出来作为一个例子记录一下. 其中还包括了,java代码的自动编译和执行,在web端显示执行结果. 下载链接: h ...

  2. openssl实现双向认证教程(服务端代码+客户端代码+证书生成)

    一.背景说明 1.1 面临问题 最近一份产品检测报告建议使用基于pki的认证方式,由于产品已实现https,商量之下认为其意思是使用双向认证以处理中间人形式攻击. <信息安全工程>中接触过 ...

  3. 使用 git post-receive 钩子部署服务端代码

    在 git 中提交服务器源码的时候,如果能够直接更新到测试服务器,并且重启服务使其生效,会节省懒惰的程序员们大量的时间. git 的 Server-side hook (服务端钩子/挂钩)可以用来做件 ...

  4. 根据wsdl,apache cxf的wsdl2java工具生成客户端、服务端代码

    根据wsdl,apache cxf的wsdl2java工具生成客户端.服务端代码 apache cxf的wsdl2java工具的简单使用: 使用步骤如下: 一.下载apache cxf的包,如apac ...

  5. HBase 协处理器编程详解第一部分:Server 端代码编写

    Hbase 协处理器 Coprocessor 简介 HBase 是一款基于 Hadoop 的 key-value 数据库,它提供了对 HDFS 上数据的高效随机读写服务,完美地填补了 Hadoop M ...

  6. Socket通信客户端和服务端代码

    这两天研究了下Socket通信,简单实现的客户端和服务端代码 先上winfrom图片,客户端和服务端一样 服务端代码: using System; using System.Collections.G ...

  7. 腾讯首页分辨手机端与pc端代码

    腾讯首页分辨手机端与pc端代码 自己在做网页的时候在腾讯网首页借鉴的代码. 代码: <!-- 移动适配JS脚本 --> <script type="text/javascr ...

  8. IOS IAP APP内支付 Java服务端代码

    IOS IAP APP内支付 Java服务端代码   场景:作为后台需要为app提供服务,在ios中,app内进行支付购买时需要进行二次验证. 基础:可以参考上一篇转载的博文In-App Purcha ...

  9. Photon Server 实现注册与登录(二) --- 服务端代码整理

    一.有的代码前端和后端都会用到.比如一些请求的Code.使用需要新建项目存放公共代码. 新建项目Common存放公共代码: EventCode :存放服务端自动发送信息给客户端的code Operat ...

随机推荐

  1. 山西汽车销量(hive)

    1.创建数据库create database db_cart; 2.使用数据库use db_cart; 3.创建表create table t_cart(province STRING,month I ...

  2. spring的基础配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  3. LeetCode——707 设计链表

    题目: 总而言之就是要用C++手撸链表,我的代码: class MyLinkedList { public: /** Initialize your data structure here. */ M ...

  4. 5款vue前端UI框架

    Vue.js是一套构建用户界面的 渐进式框架.与其他重量级框架不同的是,Vue 采用自底向上增量开发的设计. 实用的 Vue.js组件库可以帮助我们快速搭建页面,下面介绍小编认为比较受欢迎的五个vue ...

  5. webpack前端模块打包器

    webpack前端模块打包器 学习网址: https://doc.webpack-china.org/concepts/ http://www.runoob.com/w3cnote/webpack-t ...

  6. 前端 CSS的选择器 高级选择器

    高级选择器分为: 后代选择器 儿子选择器 并集选择器 交集选择器 后代选择器 使用空格表示后代选择器.父元素的后代(包括儿子,孙子,重孙子) 后代选择器 在CSS中使用非常频繁 因为HTML元素可以嵌 ...

  7. SCUT - 38 - 屠场的秘密 - 分解

    https://scut.online/p/38 要求是2016的倍数,把每个数分解成有2016的倍数和余数,两数余数的乘积是2016的倍数,则原数的乘积也是2016的倍数.

  8. jQuery淡入淡出瀑布流效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. PowerDesigner 使用说明

    1. 附加:工具栏不见了 调色板(Palette)快捷工具栏不见了PowerDesigner 快捷工具栏 palette 不见了,怎么重新打开,找回来呢 上网搜索了一下"powerdesig ...

  10. sql基本语法大全

    一.定义变量--简单赋值 declare @a intset @a=5 print @a --使用select语句赋值 declare @user1 nvarchar(50) select @user ...