Flutter端代码
新建一个页面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端代码的更多相关文章
- web端代码提示
web端代码提示 这个功能是基本完成了,但是与需求不一致.但是废弃挺可惜的,所以就单独拿出来作为一个例子记录一下. 其中还包括了,java代码的自动编译和执行,在web端显示执行结果. 下载链接: h ...
- openssl实现双向认证教程(服务端代码+客户端代码+证书生成)
一.背景说明 1.1 面临问题 最近一份产品检测报告建议使用基于pki的认证方式,由于产品已实现https,商量之下认为其意思是使用双向认证以处理中间人形式攻击. <信息安全工程>中接触过 ...
- 使用 git post-receive 钩子部署服务端代码
在 git 中提交服务器源码的时候,如果能够直接更新到测试服务器,并且重启服务使其生效,会节省懒惰的程序员们大量的时间. git 的 Server-side hook (服务端钩子/挂钩)可以用来做件 ...
- 根据wsdl,apache cxf的wsdl2java工具生成客户端、服务端代码
根据wsdl,apache cxf的wsdl2java工具生成客户端.服务端代码 apache cxf的wsdl2java工具的简单使用: 使用步骤如下: 一.下载apache cxf的包,如apac ...
- HBase 协处理器编程详解第一部分:Server 端代码编写
Hbase 协处理器 Coprocessor 简介 HBase 是一款基于 Hadoop 的 key-value 数据库,它提供了对 HDFS 上数据的高效随机读写服务,完美地填补了 Hadoop M ...
- Socket通信客户端和服务端代码
这两天研究了下Socket通信,简单实现的客户端和服务端代码 先上winfrom图片,客户端和服务端一样 服务端代码: using System; using System.Collections.G ...
- 腾讯首页分辨手机端与pc端代码
腾讯首页分辨手机端与pc端代码 自己在做网页的时候在腾讯网首页借鉴的代码. 代码: <!-- 移动适配JS脚本 --> <script type="text/javascr ...
- IOS IAP APP内支付 Java服务端代码
IOS IAP APP内支付 Java服务端代码 场景:作为后台需要为app提供服务,在ios中,app内进行支付购买时需要进行二次验证. 基础:可以参考上一篇转载的博文In-App Purcha ...
- Photon Server 实现注册与登录(二) --- 服务端代码整理
一.有的代码前端和后端都会用到.比如一些请求的Code.使用需要新建项目存放公共代码. 新建项目Common存放公共代码: EventCode :存放服务端自动发送信息给客户端的code Operat ...
随机推荐
- python 正则表达式 re.sub & re.subn
Grammar: re.sub(pattern, repl, string[, count]) 使用repl替换string中每一个匹配的子串后返回替换后的字符串.当repl是一个字符串时,可以使用\ ...
- 【SD系列】SAP SD模块-公司间销售简介
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[SD系列]SAP SD模块-公司间销售简介 ...
- JQ判断div是否隐藏
1. $("#tanchuBg").css("display") 2. $("#tanchuBg").is(":visible ...
- <每日一题> Day7:CodeForces-1166C.A Tale of Two Lands (二分 + 排序)
原题链接 参考代码: #include <cstdio> #define mid ((l + r) / 2) #include <algorithm> using namesp ...
- 创建Spring Boot微服务项目
创建一个测试用的微服务项目HelloWorld 创建项目 编写服务代码 @RestController public class HelloWorld { @RequestMapping(" ...
- SpringMVC Controller单例和多例(转)
首先上测试代码 import org.springframework.context.annotation.Scope; import org.springframework.stereotype.C ...
- Aurora测试----随机数字产生
在xilinx模板中,存在一个Aurora样本工程,包含众多的子函数,本系列本文将逐一对其进行解析,首先是aurora_8b10b_0_FRAME_GEN函数,根据官方的说明,其作用是:该模块是一个模 ...
- EF6 MySQL错误之“Specified key was too long; max key length is 767 bytes”
由于 MySQL Innodb 引擎表索引字段长度的限制为 767 字节,因此对于多字节字符集的大字段(或者多字段组合索引),创建索引会出现上面的错误. 以 utf8mb4 字符集 字符串类型字段为例 ...
- mysql中explain输出列之id的用法详解
参考mysql5.7 en manual,对列id的解释: The SELECT identifier. This is the sequential number of the SELECT wit ...
- 2018-8-10-WPF-控件继承树
title author date CreateTime categories WPF 控件继承树 lindexi 2018-08-10 19:16:53 +0800 2018-2-13 17:23: ...