添加源码文件
|
@ -0,0 +1,67 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class Product {
|
||||
final String title;
|
||||
final String description;
|
||||
|
||||
Product(this.title, this.description);
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
title: '传递数据示例',
|
||||
home: new ProductList(
|
||||
products:
|
||||
new List.generate(20, (i) => new Product('商品 $i', '这是一个商品详情 $i')),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
class ProductList extends StatelessWidget {
|
||||
final List<Product> products;
|
||||
|
||||
ProductList({Key key, @required this.products}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("商品列表"),
|
||||
),
|
||||
body: new ListView.builder(
|
||||
itemCount: products.length,
|
||||
itemBuilder: (context, index) {
|
||||
return new ListTile(
|
||||
title: new Text(products[index].title),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
new MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
new ProductDetail(product: products[index])),
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProductDetail extends StatelessWidget {
|
||||
final Product product;
|
||||
|
||||
ProductDetail({Key key, @required this.product}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("${product.title}"),
|
||||
),
|
||||
body: new Padding(
|
||||
padding: new EdgeInsets.all(16.0),
|
||||
child: new Text('${product.description}'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
title: '导航页面示例',
|
||||
home: new FirstScreen(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
class FirstScreen extends StatelessWidget {
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('导航页面示例'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new RaisedButton(
|
||||
child: new Text('查看商品详情页面'),
|
||||
onPressed: (){
|
||||
Navigator.push(
|
||||
context,
|
||||
new MaterialPageRoute(builder: (context) => new SecondScreen())
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SecondScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("导航页面示例"),
|
||||
),
|
||||
body: new Center(
|
||||
child: new RaisedButton(
|
||||
onPressed: (){
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: new Text('返回页面'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
title: '页面跳转返回数据示例',
|
||||
home: new FirstPage(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
class FirstPage extends StatelessWidget {
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("页面跳转返回数据示例"),
|
||||
),
|
||||
body: new Center(child: new RouteButton(),),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RouteButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return new RaisedButton(
|
||||
onPressed: (){
|
||||
_navigateToSecondPage(context);
|
||||
},
|
||||
child: new Text('跳转到第二个页面'),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
_navigateToSecondPage(BuildContext context) async {
|
||||
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
new MaterialPageRoute(builder: (context) => new SecondPage()),
|
||||
);
|
||||
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(content: new Text("$result")));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SecondPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("选择一条数据"),
|
||||
),
|
||||
body: new Center(
|
||||
child: new Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new RaisedButton(
|
||||
onPressed: (){
|
||||
Navigator.pop(context,'hi google');
|
||||
},
|
||||
child: new Text('hi google'),
|
||||
),
|
||||
),
|
||||
new Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new RaisedButton(
|
||||
onPressed: (){
|
||||
Navigator.pop(context,'hi flutter');
|
||||
},
|
||||
child: new Text('hi flutter'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'ClipOval圆形剪裁示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'ClipOval圆形剪裁示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: new ClipOval(
|
||||
child: new SizedBox(
|
||||
width: 300.0,
|
||||
height: 300.0,
|
||||
child: new Image.asset(
|
||||
"images/8.jpeg",
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'ClipPath路径剪裁示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'ClipPath路径剪裁示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: new ClipPath(
|
||||
clipper: new TriangleCliper(),//指定自定义三角形Clipper
|
||||
child:new SizedBox(
|
||||
width: 100.0,
|
||||
height:100.0,
|
||||
child: new Image.asset("images/8.jpeg",fit: BoxFit.fill,),
|
||||
) ,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//自定义三角形Clipper,类型为Path
|
||||
class TriangleCliper extends CustomClipper<Path>{
|
||||
|
||||
//重写获取剪裁范围
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
|
||||
Path path = new Path();
|
||||
path.moveTo(50.0,50.0);//起始点
|
||||
path.lineTo(50.0,10.0);//终止点
|
||||
path.lineTo(100.0,50.0);//起始点(50,10),终止点
|
||||
path.close();//使这些点构成三角形
|
||||
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
//重写是否重新剪裁
|
||||
@override
|
||||
bool shouldReclip(TriangleCliper oldClipper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'ClipRRect圆角矩形剪裁示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'ClipRRect圆角矩形剪裁示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: new ClipRRect(
|
||||
borderRadius: new BorderRadius.all(
|
||||
new Radius.circular(30.0)),//圆角弧度,值越大弧度越大
|
||||
child: new SizedBox(
|
||||
width: 300.0,
|
||||
height: 300.0,
|
||||
child: new Image.asset(
|
||||
"images/8.jpeg",
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'ClipRect矩形剪裁示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'ClipRect矩形剪裁示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: new ClipRect(
|
||||
clipper: new RectClipper(),//指定自定义Clipper
|
||||
child:new SizedBox(
|
||||
width: 300.0,
|
||||
height:300.0,
|
||||
child: new Image.asset("images/8.jpeg",fit: BoxFit.fill,),
|
||||
) ,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//自定义Clipper,类型为Rect
|
||||
class RectClipper extends CustomClipper<Rect>{
|
||||
|
||||
//重写获取剪裁范围
|
||||
@override
|
||||
Rect getClip(Size size) {
|
||||
return new Rect.fromLTRB(100.0, 100.0, size.width - 100.0, size.height- 100.0);
|
||||
}
|
||||
|
||||
//重写是否重新剪裁
|
||||
@override
|
||||
bool shouldReclip(CustomClipper<Rect> oldClipper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制圆示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制圆示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'绘制圆',
|
||||
style: const TextStyle(
|
||||
fontSize: 38.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.grey
|
||||
..strokeCap = StrokeCap.square
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 3.0
|
||||
..style = PaintingStyle.stroke;//画笔样式有填充PaintingStyle.fill及没有填充PaintingStyle.stroke两种
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
//绘制圆 参数为中心点,半径,画笔
|
||||
canvas.drawCircle(Offset(200.0, 150.0), 150.0, _paint);
|
||||
}
|
||||
|
||||
///重写是否需要重绘的
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:ui';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制圆弧示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制圆弧示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.grey
|
||||
..strokeCap = StrokeCap.round
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 2.0//画笔粗细
|
||||
..style = PaintingStyle.stroke; //用于绘制点时PaintingStyle值无效
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
//绘制圆弧
|
||||
const PI = 3.1415926;
|
||||
//定义矩形
|
||||
Rect rect1 = Rect.fromCircle(center: Offset(100.0, 0.0), radius: 100.0);
|
||||
//画1/2PI弧度的圆弧
|
||||
canvas.drawArc(rect1, 0.0, PI / 2, true, _paint);
|
||||
//画PI弧度的圆弧
|
||||
Rect rect2 = Rect.fromCircle(center: Offset(200.0, 150.0), radius: 100.0);
|
||||
canvas.drawArc(rect2, 0.0, PI, true, _paint);
|
||||
}
|
||||
|
||||
///是否需要重绘
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制圆角矩形示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制圆角矩形示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'绘制圆角矩形',
|
||||
style: const TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.grey
|
||||
..strokeCap = StrokeCap.square
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 3.0
|
||||
..style = PaintingStyle.stroke;//画笔样式有填充PaintingStyle.fill及没有填充PaintingStyle.stroke两种
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
|
||||
//中心点坐标为200,200 边长为100
|
||||
Rect rect = Rect.fromCircle(center: Offset(200.0, 200.0), radius: 100.0);
|
||||
//根据矩形创建一个角度为10的圆角矩形
|
||||
RRect rrect = RRect.fromRectAndRadius(rect, Radius.circular(20.0));
|
||||
//开始绘制圆角矩形
|
||||
canvas.drawRRect(rrect, _paint);
|
||||
}
|
||||
|
||||
///是否需要重绘
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:ui';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制多个点示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制多个点示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.grey
|
||||
..strokeCap = StrokeCap.round//StrokeCap.round为圆点 StrokeCap.square为方形
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 20.0//画笔粗细 值调大点 这样点看起来明显一些
|
||||
..style = PaintingStyle.fill; //用于绘制点时PaintingStyle值无效
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
//绘制点
|
||||
canvas.drawPoints(
|
||||
|
||||
///PointMode的枚举类型有三个,points点,lines隔点连接线,polygon相邻连接线
|
||||
PointMode.points,
|
||||
[
|
||||
Offset(50.0, 60.0),
|
||||
Offset(40.0, 90.0),
|
||||
Offset(100.0, 100.0),
|
||||
Offset(300.0, 350.0),
|
||||
Offset(400.0, 80.0),
|
||||
Offset(200.0, 200.0),
|
||||
],
|
||||
_paint..color = Colors.grey);
|
||||
}
|
||||
|
||||
///是否需要重绘
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制嵌套矩形示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制嵌套矩形示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.grey
|
||||
..strokeCap = StrokeCap.square
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 3.0
|
||||
..style = PaintingStyle.stroke;//画笔样式有填充PaintingStyle.fill及没有填充PaintingStyle.stroke两种
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
|
||||
//初始化两个矩形
|
||||
Rect rect1 = Rect.fromCircle(center: Offset(150.0, 150.0), radius: 80.0);
|
||||
Rect rect2 = Rect.fromCircle(center: Offset(150.0, 150.0), radius: 40.0);
|
||||
//再把这两个矩形转化成圆角矩形
|
||||
RRect outer = RRect.fromRectAndRadius(rect1, Radius.circular(20.0));
|
||||
RRect inner = RRect.fromRectAndRadius(rect2, Radius.circular(10.0));
|
||||
canvas.drawDRRect(outer, inner, _paint);
|
||||
}
|
||||
|
||||
///是否需要重绘
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制椭圆示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制椭圆示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'绘制椭圆',
|
||||
style: const TextStyle(
|
||||
fontSize: 38.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.grey
|
||||
..strokeCap = StrokeCap.square
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 3.0
|
||||
..style = PaintingStyle.fill;//画笔样式有填充PaintingStyle.fill及没有填充PaintingStyle.stroke两种
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
//绘制椭圆
|
||||
//使用一个矩形来确定绘制的范围,椭圆是在这个矩形之中内切的,第一个参数为左上角坐标,第二个参数为右下角坐标
|
||||
Rect rect = Rect.fromPoints(Offset(80.0, 200.0), Offset(300.0, 300.0));
|
||||
canvas.drawOval(rect, _paint);
|
||||
}
|
||||
|
||||
///重写是否需要重绘的
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制直线示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制直线示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'绘制直线',
|
||||
style: const TextStyle(
|
||||
fontSize: 38.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.black
|
||||
..strokeCap = StrokeCap.square
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 3.0
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
//绘制直线
|
||||
canvas.drawLine(Offset(20.0, 20.0), Offset(300.0, 20.0), _paint);
|
||||
}
|
||||
|
||||
///重写是否需要重绘的
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:ui';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'CustomPaint绘制路径示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'CustomPaint绘制路径示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: CustomPaint(
|
||||
painter: LinePainter(),
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//继承于CustomPainter并且实现CustomPainter里面的paint和shouldRepaint方法
|
||||
class LinePainter extends CustomPainter {
|
||||
//定义画笔
|
||||
Paint _paint = new Paint()
|
||||
..color = Colors.grey
|
||||
..strokeCap = StrokeCap.round
|
||||
..isAntiAlias = true
|
||||
..strokeWidth = 2.0 //画笔粗细
|
||||
..style = PaintingStyle.stroke; //用于绘制点时PaintingStyle值无效
|
||||
|
||||
///重写绘制内容方法
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
//新建一个path移动到一个位置,然后画各种线
|
||||
Path path = new Path()..moveTo(100.0, 100.0);
|
||||
path.lineTo(200.0, 300.0);
|
||||
path.lineTo(100.0, 200.0);
|
||||
path.lineTo(150.0, 250.0);
|
||||
path.lineTo(150.0, 500.0);
|
||||
canvas.drawPath(path, _paint);
|
||||
}
|
||||
|
||||
///是否需要重绘
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class LayoutDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('LinearGradient线性渐变效果'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new DecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
gradient: new LinearGradient(
|
||||
begin: const FractionalOffset(0.5, 0.0),//起始偏移量
|
||||
end: const FractionalOffset(1.0, 1.0),//终止偏移量
|
||||
//渐变颜色数据集
|
||||
colors: <Color>[
|
||||
Colors.red,
|
||||
Colors.green,
|
||||
Colors.blue,
|
||||
Colors.grey,
|
||||
],
|
||||
),
|
||||
),
|
||||
child: new Container(
|
||||
width: 280.0,
|
||||
height: 280.0,
|
||||
child: new Center(
|
||||
child: Text(
|
||||
'LinearGradient线性渐变效果',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 28.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
new MaterialApp(
|
||||
title: 'DecoratedBox装饰盒子示例',
|
||||
home: new LayoutDemo(),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class LayoutDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('RadialGradient环形渐变效果'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new DecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
gradient: RadialGradient(
|
||||
center: const Alignment(-0.0, -0.0), //中心点偏移量,x和y均为0.0表示在正中心位置
|
||||
radius: 0.50, //圆形半径
|
||||
//渐变颜色数据集
|
||||
colors: <Color>[
|
||||
Colors.red,
|
||||
Colors.green,
|
||||
Colors.blue,
|
||||
Colors.grey,
|
||||
],
|
||||
),
|
||||
),
|
||||
child: new Container(
|
||||
width: 280.0,
|
||||
height: 280.0,
|
||||
child: new Center(
|
||||
child: Text(
|
||||
'RadialGradient环形渐变效果',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 28.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
new MaterialApp(
|
||||
title: 'DecoratedBox装饰盒子示例',
|
||||
home: new LayoutDemo(),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:flutter/material.dart';
|
||||
class LayoutDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('BoxDecoration装饰盒子-背景图示例'),
|
||||
),
|
||||
body: new Center(
|
||||
child: Container(
|
||||
width: 300.0,
|
||||
height: 300.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
image: DecorationImage(
|
||||
image: ExactAssetImage('images/1.jpeg'),//添加image属性
|
||||
fit: BoxFit.cover,//填充类型
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
void main() {
|
||||
runApp(
|
||||
new MaterialApp(
|
||||
title: 'BoxDecoration装饰盒子-背景图示例',
|
||||
home: new LayoutDemo(),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class LayoutDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('BoxDecoration装饰盒子-边框圆角示例'),
|
||||
),
|
||||
body: new Center(
|
||||
child: Container(
|
||||
width: 260.0,
|
||||
height: 260.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.grey, width: 4.0),
|
||||
//添加所有的边框,颜色为灰色,宽度为4.0
|
||||
borderRadius: BorderRadius.circular(36.0),
|
||||
//添加边框弧度,这样会有一个圆角效果
|
||||
image: DecorationImage(
|
||||
image: ExactAssetImage('images/1.jpeg'), //添加image属性
|
||||
fit: BoxFit.cover, //填充类型
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
new MaterialApp(
|
||||
title: 'BoxDecoration装饰盒子-边框圆角示例',
|
||||
home: new LayoutDemo(),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class LayoutDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('BoxDecoration装饰盒子-边框阴影示例'),
|
||||
),
|
||||
body: new Center(
|
||||
child: Container(
|
||||
width: 300.0,
|
||||
height: 300.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
//边框阴影效果
|
||||
boxShadow: <BoxShadow>[
|
||||
new BoxShadow(
|
||||
color: Colors.grey, //阴影颜色
|
||||
blurRadius: 8.0, //模糊值
|
||||
spreadRadius: 8.0, //扩展阴影半径
|
||||
offset: Offset(-1.0, 1.0), //x/y方向偏移量
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
'BoxShadow阴影效果',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 28.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
new MaterialApp(
|
||||
title: 'BoxDecoration装饰盒子-边框阴影示例',
|
||||
home: new LayoutDemo(),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class LayoutDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('Opacity不透明度示例'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new Opacity(
|
||||
opacity: 0.3, //不透明度设置为0.3
|
||||
child: new Container(
|
||||
width: 250.0,
|
||||
height: 100.0,
|
||||
decoration: new BoxDecoration(
|
||||
color: Colors.black, //背景色设置为纯黑
|
||||
),
|
||||
child: Text(
|
||||
'不透明度为0.3',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 28.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
new MaterialApp(
|
||||
title: 'Opacity不透明度示例',
|
||||
home: new LayoutDemo(),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'RotatedBox旋转盒子示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'RotatedBox旋转盒子示例',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: RotatedBox(
|
||||
quarterTurns: 3,//旋转次数,一次为90度
|
||||
child: Text(
|
||||
'RotatedBox旋转盒子',
|
||||
style: TextStyle(fontSize: 28.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appTitle = "淡入淡出动画示例";
|
||||
return new MaterialApp(
|
||||
title: appTitle,
|
||||
home: new MyHomePage(title:appTitle),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
final String title;
|
||||
|
||||
MyHomePage({Key key,this.title}):super(key:key);
|
||||
|
||||
@override
|
||||
_MyHomePageState createState() => new _MyHomePageState();
|
||||
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
//控制动画显示状态变量
|
||||
bool _visible = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text(widget.title),
|
||||
),
|
||||
body: new Center(
|
||||
//添加Opacity动画
|
||||
child: new AnimatedOpacity(
|
||||
//控制opacity值 范围从0.0到1.0
|
||||
opacity: _visible ? 1.0 : 0.0,
|
||||
//设置动画时长
|
||||
duration: new Duration(
|
||||
milliseconds: 1000
|
||||
),
|
||||
child: new Container(
|
||||
width: 300.0,
|
||||
height: 300.0,
|
||||
color: Colors.deepPurple,
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
onPressed: (){
|
||||
//控制动画显示状态
|
||||
setState(() {
|
||||
_visible = !_visible;
|
||||
});
|
||||
},
|
||||
tooltip: "显示隐藏",
|
||||
child: new Icon(Icons.flip),
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
title: '页面切换动画',
|
||||
home: new FirstPage(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
class FirstPage extends StatelessWidget {
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("页面切换动画图一"),
|
||||
),
|
||||
body: new GestureDetector(
|
||||
child: new Hero(
|
||||
tag: '第一张图片',
|
||||
child: new Image.network(
|
||||
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1541753399410&di=05760e1c65686b018cf28d440a6ddf5c&imgtype=0&src=http%3A%2F%2Fimg1.cache.netease.com%2Fcatchpic%2FD%2FD7%2FD7D7640C07A00D831EFD2AC270ED7FA7.jpg",
|
||||
),
|
||||
),
|
||||
onTap: (){
|
||||
Navigator.push(context, new MaterialPageRoute(builder: (_){
|
||||
return new SecondPage();
|
||||
}));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SecondPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("页面切换动画图二"),
|
||||
),
|
||||
body: new GestureDetector(
|
||||
|
||||
child: new Hero(
|
||||
tag: "第二张图片",
|
||||
child: new Image.network("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1541753302014&di=9edfe992f8b9d395134fd977dbfeab28&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F2f738bd4b31c870143a3a1dc2c7f9e2f0708fff7.jpg"),
|
||||
),
|
||||
|
||||
|
||||
onTap: (){
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
pubspec.lock
|
||||
|
||||
build/
|
|
@ -0,0 +1,29 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<Objective-C-extensions>
|
||||
<file>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||
</file>
|
||||
<class>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||
</class>
|
||||
<extensions>
|
||||
<pair source="cpp" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
</code_scheme>
|
||||
</component>
|
|
@ -0,0 +1,19 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Dart SDK">
|
||||
<CLASSES>
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/async" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/collection" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/convert" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/core" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/developer" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/html" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/io" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/isolate" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/math" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/mirrors" />
|
||||
<root url="file:///Users/ksj/Desktop/flutter/flutter/bin/cache/dart-sdk/lib/typed_data" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,9 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Flutter Plugins" type="FlutterPluginsLibraryType">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,9 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Flutter for Android">
|
||||
<CLASSES>
|
||||
<root url="jar:///Users/ksj/Desktop/flutter/flutter/bin/cache/artifacts/engine/android-arm/flutter.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" project-jdk-name="Android API 17 Platform" project-jdk-type="Android SDK" />
|
||||
</project>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/flutter_plugin_demo.iml" filepath="$PROJECT_DIR$/flutter_plugin_demo.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/android/flutter_plugin_demo_android.iml" filepath="$PROJECT_DIR$/android/flutter_plugin_demo_android.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/example/android/flutter_plugin_demo_example_android.iml" filepath="$PROJECT_DIR$/example/android/flutter_plugin_demo_example_android.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="example/lib/main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="filePath" value="$PROJECT_DIR$/example/lib/main.dart" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,302 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9e549be3-8dd9-4d40-9580-25d05b917d30" name="Default" comment="" />
|
||||
<ignored path="$PROJECT_DIR$/.dart_tool/" />
|
||||
<ignored path="$PROJECT_DIR$/.idea/" />
|
||||
<ignored path="$PROJECT_DIR$/.pub/" />
|
||||
<ignored path="$PROJECT_DIR$/build/" />
|
||||
<ignored path="$PROJECT_DIR$/example/.pub/" />
|
||||
<ignored path="$PROJECT_DIR$/example/build/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="main.dart" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="51">
|
||||
<caret line="3" column="30" lean-forward="false" selection-start-line="3" selection-start-column="30" selection-end-line="3" selection-end-column="30" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="GradleLocalSettings">
|
||||
<option name="externalProjectsViewState">
|
||||
<projects_view />
|
||||
</option>
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/lib/flutter_plugin_demo.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/main.dart" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1440" />
|
||||
<option name="height" value="841" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
<showLibraryContents />
|
||||
<hideEmptyPackages />
|
||||
<abbreviatePackageNames />
|
||||
<autoscrollToSource />
|
||||
<autoscrollFromSource />
|
||||
<sortByType />
|
||||
<manualOrder />
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scratches" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="flutter_plugin_demo" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_plugin_demo" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_plugin_demo" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_plugin_demo" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_plugin_demo" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_plugin_demo" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
<option name="show-excluded-files" value="false" />
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
<pane id="AndroidView" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="dart.analysis.tool.window.force.activate" value="false" />
|
||||
<property name="show.migrate.to.gradle.popup" value="false" />
|
||||
<property name="io.flutter.reload.alreadyRun" value="true" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="AndroidJUnit" factoryName="Android JUnit">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<module name="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="PACKAGE_NAME" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="METHOD_NAME" />
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="singleModule" />
|
||||
</option>
|
||||
<envs />
|
||||
<patterns />
|
||||
</configuration>
|
||||
<configuration default="true" type="Application" factoryName="Application">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="" />
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration default="true" type="Remote" factoryName="Remote">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
</configuration>
|
||||
<configuration default="true" type="TestNG" factoryName="TestNG">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<module name="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="SUITE_NAME" />
|
||||
<option name="PACKAGE_NAME" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="METHOD_NAME" />
|
||||
<option name="GROUP_NAME" />
|
||||
<option name="TEST_OBJECT" value="CLASS" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
|
||||
<option name="OUTPUT_DIRECTORY" />
|
||||
<option name="ANNOTATION_TYPE" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="singleModule" />
|
||||
</option>
|
||||
<option name="USE_DEFAULT_REPORTERS" value="false" />
|
||||
<option name="PROPERTIES_FILE" />
|
||||
<envs />
|
||||
<properties />
|
||||
<listeners />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="Applet" default="true" selected="false">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="HTML_FILE_NAME" />
|
||||
<option name="HTML_USED" value="false" />
|
||||
<option name="WIDTH" value="400" />
|
||||
<option name="HEIGHT" value="300" />
|
||||
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="JUnit" default="true" selected="false">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
|
||||
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="ShelveChangesManager" show_recycled="false">
|
||||
<option name="remove_strategy" value="false" />
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="9e549be3-8dd9-4d40-9580-25d05b917d30" name="Default" comment="" />
|
||||
<created>1543546180452</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1543546180452</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="23" width="1440" height="841" extended-state="0" />
|
||||
<layout>
|
||||
<window_info id="Android Profiler" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Palette	" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Dart Analysis" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32918397" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Flutter Outline" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Logcat" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Captures" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.26108727" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Device File Explorer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.109266944" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Flutter Inspector" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.13948497" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/android/src/main/java/demo/com/flutterplugindemo/FlutterPluginDemoPlugin.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="289">
|
||||
<caret line="21" column="30" lean-forward="true" selection-start-line="21" selection-start-column="30" selection-end-line="21" selection-end-column="30" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/flutter_plugin_demo.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="136">
|
||||
<caret line="8" column="0" lean-forward="true" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="442">
|
||||
<caret line="26" column="8" lean-forward="true" selection-start-line="26" selection-start-column="8" selection-end-line="26" selection-end-column="8" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="51">
|
||||
<caret line="3" column="30" lean-forward="false" selection-start-line="3" selection-start-column="30" selection-end-line="3" selection-end-column="30" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,10 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 06ec8d3b41beb469d845626e36a246ee09300fa7
|
||||
channel: beta
|
||||
|
||||
project_type: plugin
|
|
@ -0,0 +1,3 @@
|
|||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
|
@ -0,0 +1,8 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
|
@ -0,0 +1,34 @@
|
|||
group 'demo.com.flutterplugindemo'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.gradle.jvmargs=-Xmx1536M
|
|
@ -0,0 +1 @@
|
|||
rootProject.name = 'flutter_plugin_demo'
|
|
@ -0,0 +1,3 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="demo.com.flutterplugindemo">
|
||||
</manifest>
|
|
@ -0,0 +1,28 @@
|
|||
package demo.com.flutterplugindemo;
|
||||
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
|
||||
/** FlutterPluginDemoPlugin */
|
||||
public class FlutterPluginDemoPlugin implements MethodCallHandler {
|
||||
/**插件注册*/
|
||||
public static void registerWith(Registrar registrar) {
|
||||
//定义与上层代码通信的通道 注意标识符要与上层代码保持一致
|
||||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_plugin_demo");
|
||||
channel.setMethodCallHandler(new FlutterPluginDemoPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMethodCall(MethodCall call, Result result) {
|
||||
//判断上层调用的方法
|
||||
if (call.method.equals("getPlatformVersion")) {
|
||||
//调用成功后返回系统版本
|
||||
result.success("Android " + android.os.Build.VERSION.RELEASE);
|
||||
} else {
|
||||
result.notImplemented();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
# Miscellaneous
|
||||
*.class
|
||||
*.lock
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Visual Studio Code related
|
||||
.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
build/
|
||||
|
||||
# Android related
|
||||
**/android/**/gradle-wrapper.jar
|
||||
**/android/.gradle
|
||||
**/android/captures/
|
||||
**/android/gradlew
|
||||
**/android/gradlew.bat
|
||||
**/android/local.properties
|
||||
**/android/**/GeneratedPluginRegistrant.java
|
||||
|
||||
# iOS/XCode related
|
||||
**/ios/**/*.mode1v3
|
||||
**/ios/**/*.mode2v3
|
||||
**/ios/**/*.moved-aside
|
||||
**/ios/**/*.pbxuser
|
||||
**/ios/**/*.perspectivev3
|
||||
**/ios/**/*sync/
|
||||
**/ios/**/.sconsign.dblite
|
||||
**/ios/**/.tags*
|
||||
**/ios/**/.vagrant/
|
||||
**/ios/**/DerivedData/
|
||||
**/ios/**/Icon?
|
||||
**/ios/**/Pods/
|
||||
**/ios/**/.symlinks/
|
||||
**/ios/**/profile
|
||||
**/ios/**/xcuserdata
|
||||
**/ios/.generated/
|
||||
**/ios/Flutter/App.framework
|
||||
**/ios/Flutter/Flutter.framework
|
||||
**/ios/Flutter/Generated.xcconfig
|
||||
**/ios/Flutter/app.flx
|
||||
**/ios/Flutter/app.zip
|
||||
**/ios/Flutter/flutter_assets/
|
||||
**/ios/ServiceDefinitions.json
|
||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!**/ios/**/default.mode1v3
|
||||
!**/ios/**/default.mode2v3
|
||||
!**/ios/**/default.pbxuser
|
||||
!**/ios/**/default.perspectivev3
|
||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
|
@ -0,0 +1,10 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 06ec8d3b41beb469d845626e36a246ee09300fa7
|
||||
channel: beta
|
||||
|
||||
project_type: app
|
|
@ -0,0 +1,51 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_plugin_demo/flutter_plugin_demo.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
@override
|
||||
_MyAppState createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
String _platformVersion = 'Unknown';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initPlatformState();
|
||||
}
|
||||
|
||||
//获取底层的方法是异步的 所以调用的方法也要异步处理才行
|
||||
Future<void> initPlatformState() async {
|
||||
String platformVersion;
|
||||
//底层方法有可能会调用失败 所以要使用try/catch语句
|
||||
try {
|
||||
platformVersion = await FlutterPluginDemo.platformVersion;
|
||||
} on PlatformException {
|
||||
platformVersion = 'Failed to get platform version.';
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_platformVersion = platformVersion;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Plugin example app'),
|
||||
),
|
||||
body: Center(
|
||||
child: Text('Running on: $_platformVersion\n'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
name: flutter_plugin_demo_example
|
||||
description: Demonstrates how to use the flutter_plugin_demo plugin.
|
||||
publish_to: 'none'
|
||||
|
||||
environment:
|
||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^0.1.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
flutter_plugin_demo:
|
||||
path: ../
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.io/assets-and-images/#resolution-aware.
|
||||
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.io/assets-and-images/#from-packages
|
||||
|
||||
# To add custom fonts to your application, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.io/custom-fonts/#from-packages
|
|
@ -0,0 +1,27 @@
|
|||
// This is a basic Flutter widget test.
|
||||
//
|
||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// utility that Flutter provides. For example, you can send tap and scroll
|
||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:flutter_plugin_demo_example/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Verify Platform version', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(MyApp());
|
||||
|
||||
// Verify that platform version is retrieved.
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Text &&
|
||||
widget.data.startsWith('Running on:'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/example/build" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Dart SDK" level="project" />
|
||||
<orderEntry type="library" name="Flutter Plugins" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,36 @@
|
|||
.idea/
|
||||
.vagrant/
|
||||
.sconsign.dblite
|
||||
.svn/
|
||||
|
||||
.DS_Store
|
||||
*.swp
|
||||
profile
|
||||
|
||||
DerivedData/
|
||||
build/
|
||||
GeneratedPluginRegistrant.h
|
||||
GeneratedPluginRegistrant.m
|
||||
|
||||
.generated/
|
||||
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
|
||||
!default.pbxuser
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.perspectivev3
|
||||
|
||||
xcuserdata
|
||||
|
||||
*.moved-aside
|
||||
|
||||
*.pyc
|
||||
*sync/
|
||||
Icon?
|
||||
.tags*
|
||||
|
||||
/Flutter/Generated.xcconfig
|
|
@ -0,0 +1,4 @@
|
|||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface FlutterPluginDemoPlugin : NSObject<FlutterPlugin>
|
||||
@end
|
|
@ -0,0 +1,24 @@
|
|||
#import "FlutterPluginDemoPlugin.h"
|
||||
|
||||
@implementation FlutterPluginDemoPlugin
|
||||
/**插件注册*/
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
//定义与上层代码通信的通道 注意标识符要与上层代码保持一致
|
||||
FlutterMethodChannel* channel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"flutter_plugin_demo"
|
||||
binaryMessenger:[registrar messenger]];
|
||||
FlutterPluginDemoPlugin* instance = [[FlutterPluginDemoPlugin alloc] init];
|
||||
[registrar addMethodCallDelegate:instance channel:channel];
|
||||
}
|
||||
|
||||
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
|
||||
//判断上层调用的方法
|
||||
if ([@"getPlatformVersion" isEqualToString:call.method]) {
|
||||
//调用成功后返回系统版本
|
||||
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,21 @@
|
|||
#
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'flutter_plugin_demo'
|
||||
s.version = '0.0.1'
|
||||
s.summary = 'A new Flutter plugin.'
|
||||
s.description = <<-DESC
|
||||
A new Flutter plugin.
|
||||
DESC
|
||||
s.homepage = 'http://example.com'
|
||||
s.license = { :file => '../LICENSE' }
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
|
||||
s.ios.deployment_target = '8.0'
|
||||
end
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class FlutterPluginDemo {
|
||||
//定义通道方法MethodChannel 通道标识这个和原生代码是对应的要保持一致
|
||||
static const MethodChannel _channel =
|
||||
const MethodChannel('flutter_plugin_demo');
|
||||
|
||||
//提供外部调用的方法 注意此方法要加异步处理
|
||||
static Future<String> get platformVersion async {
|
||||
//调用原生程序获取系统版本
|
||||
final String version = await _channel.invokeMethod('getPlatformVersion');
|
||||
return version;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
name: flutter_plugin_demo
|
||||
description: A new Flutter plugin.
|
||||
version: 0.0.1
|
||||
author:
|
||||
homepage:
|
||||
|
||||
environment:
|
||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
# This section identifies this Flutter project as a plugin project.
|
||||
# The androidPackage and pluginClass identifiers should not ordinarily
|
||||
# be modified. They are used by the tooling to maintain consistency when
|
||||
# adding or updating assets for this project.
|
||||
plugin:
|
||||
androidPackage: demo.com.flutterplugindemo
|
||||
pluginClass: FlutterPluginDemoPlugin
|
||||
|
||||
# To add assets to your plugin package, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
#
|
||||
# For details regarding assets in packages, see
|
||||
# https://flutter.io/assets-and-images/#from-packages
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.io/assets-and-images/#resolution-aware.
|
||||
|
||||
# To add custom fonts to your plugin package, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts in packages, see
|
||||
# https://flutter.io/custom-fonts/#from-packages
|
|
@ -0,0 +1,71 @@
|
|||
# Miscellaneous
|
||||
*.class
|
||||
*.lock
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Visual Studio Code related
|
||||
.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
build/
|
||||
|
||||
# Android related
|
||||
**/android/**/gradle-wrapper.jar
|
||||
**/android/.gradle
|
||||
**/android/captures/
|
||||
**/android/gradlew
|
||||
**/android/gradlew.bat
|
||||
**/android/local.properties
|
||||
**/android/**/GeneratedPluginRegistrant.java
|
||||
|
||||
# iOS/XCode related
|
||||
**/ios/**/*.mode1v3
|
||||
**/ios/**/*.mode2v3
|
||||
**/ios/**/*.moved-aside
|
||||
**/ios/**/*.pbxuser
|
||||
**/ios/**/*.perspectivev3
|
||||
**/ios/**/*sync/
|
||||
**/ios/**/.sconsign.dblite
|
||||
**/ios/**/.tags*
|
||||
**/ios/**/.vagrant/
|
||||
**/ios/**/DerivedData/
|
||||
**/ios/**/Icon?
|
||||
**/ios/**/Pods/
|
||||
**/ios/**/.symlinks/
|
||||
**/ios/**/profile
|
||||
**/ios/**/xcuserdata
|
||||
**/ios/.generated/
|
||||
**/ios/Flutter/App.framework
|
||||
**/ios/Flutter/Flutter.framework
|
||||
**/ios/Flutter/Generated.xcconfig
|
||||
**/ios/Flutter/app.flx
|
||||
**/ios/Flutter/app.zip
|
||||
**/ios/Flutter/flutter_assets/
|
||||
**/ios/ServiceDefinitions.json
|
||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!**/ios/**/default.mode1v3
|
||||
!**/ios/**/default.mode2v3
|
||||
!**/ios/**/default.pbxuser
|
||||
!**/ios/**/default.perspectivev3
|
||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
|
@ -0,0 +1,10 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
|
||||
channel: beta
|
||||
|
||||
project_type: app
|
|
@ -0,0 +1,16 @@
|
|||
# flutter_im
|
||||
|
||||
A new Flutter application.
|
||||
|
||||
## Getting Started
|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
|
||||
- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
|
||||
|
||||
For help getting started with Flutter, view our
|
||||
[online documentation](https://flutter.io/docs), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 651 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 679 B |
After Width: | Height: | Size: 914 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1021 B |
After Width: | Height: | Size: 7.1 KiB |
|
@ -0,0 +1,202 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './chat/message_page.dart';
|
||||
import './contacts/contacts.dart';
|
||||
import './personal/personal.dart';
|
||||
|
||||
//应用页面使用有状态Widget
|
||||
class App extends StatefulWidget {
|
||||
@override
|
||||
AppState createState() => AppState();
|
||||
}
|
||||
|
||||
//应用页面状态实现类
|
||||
class AppState extends State<App> {
|
||||
//当前选中页面索引
|
||||
var _currentIndex = 0;
|
||||
|
||||
//聊天页面
|
||||
MessagePage message;
|
||||
|
||||
//好友页面
|
||||
Contacts contacts;
|
||||
|
||||
//我的页面
|
||||
Personal me;
|
||||
|
||||
//根据当前索引返回不同的页面
|
||||
currentPage() {
|
||||
switch (_currentIndex) {
|
||||
case 0:
|
||||
if (message == null) {
|
||||
message = new MessagePage();
|
||||
}
|
||||
return message;
|
||||
case 1:
|
||||
if (contacts == null) {
|
||||
contacts = new Contacts();
|
||||
}
|
||||
return contacts;
|
||||
case 2:
|
||||
if (me == null) {
|
||||
me = new Personal();
|
||||
}
|
||||
return me;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
//渲染某个菜单项 传入菜单标题 图片路径或图标
|
||||
_popupMenuItem(String title, {String imagePath, IconData icon}) {
|
||||
return PopupMenuItem(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
//判断是使用图片路径还是图标
|
||||
imagePath != null
|
||||
? Image.asset(
|
||||
imagePath,
|
||||
width: 32.0,
|
||||
height: 32.0,
|
||||
)
|
||||
: SizedBox(
|
||||
width: 32.0,
|
||||
height: 32.0,
|
||||
child: Icon(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
//显示菜单项文本内容
|
||||
Container(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('即时通讯'),
|
||||
actions: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
//跳转至搜索页面
|
||||
Navigator.pushNamed(context, 'search');
|
||||
},
|
||||
child: Icon(
|
||||
//搜索图标
|
||||
Icons.search,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
//左右内边距
|
||||
padding: const EdgeInsets.only(left: 30.0, right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
//弹出菜单
|
||||
showMenu(
|
||||
context: context,
|
||||
//定位在界面的右上角
|
||||
position: RelativeRect.fromLTRB(500.0, 76.0, 10.0, 0.0),
|
||||
//展示所有菜单项
|
||||
items: <PopupMenuEntry>[
|
||||
_popupMenuItem('发起会话',
|
||||
imagePath: 'images/icon_menu_group.png'),
|
||||
_popupMenuItem('添加好友',
|
||||
imagePath: 'images/icon_menu_addfriend.png'),
|
||||
_popupMenuItem('联系客服', icon: Icons.person),
|
||||
],
|
||||
);
|
||||
},
|
||||
//菜单按钮
|
||||
child: Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
//底部导航按钮
|
||||
bottomNavigationBar: new BottomNavigationBar(
|
||||
//通过fixedColor设置选中item 的颜色
|
||||
type: BottomNavigationBarType.fixed,
|
||||
//当前页面索引
|
||||
currentIndex: _currentIndex,
|
||||
//按下后设置当前页面索引
|
||||
onTap: ((index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
}),
|
||||
//底部导航按钮项
|
||||
items: [
|
||||
//导航按钮项传入文本及图标
|
||||
new BottomNavigationBarItem(
|
||||
title: new Text(
|
||||
'聊天',
|
||||
style: TextStyle(
|
||||
color: _currentIndex == 0
|
||||
? Color(0xFF46c01b)
|
||||
: Color(0xff999999)),
|
||||
),
|
||||
//判断当前索引作图片切换显示
|
||||
icon: _currentIndex == 0
|
||||
? Image.asset(
|
||||
'images/message_pressed.png',
|
||||
width: 32.0,
|
||||
height: 28.0,
|
||||
)
|
||||
: Image.asset(
|
||||
'images/message_normal.png',
|
||||
width: 32.0,
|
||||
height: 28.0,
|
||||
)),
|
||||
new BottomNavigationBarItem(
|
||||
title: new Text(
|
||||
'好友',
|
||||
style: TextStyle(
|
||||
color: _currentIndex == 1
|
||||
? Color(0xFF46c01b)
|
||||
: Color(0xff999999)),
|
||||
),
|
||||
icon: _currentIndex == 1
|
||||
? Image.asset(
|
||||
'images/contact_list_pressed.png',
|
||||
width: 32.0,
|
||||
height: 28.0,
|
||||
)
|
||||
: Image.asset(
|
||||
'images/contact_list_normal.png',
|
||||
width: 32.0,
|
||||
height: 28.0,
|
||||
)),
|
||||
new BottomNavigationBarItem(
|
||||
title: new Text(
|
||||
'我的',
|
||||
style: TextStyle(
|
||||
color: _currentIndex == 2
|
||||
? Color(0xFF46c01b)
|
||||
: Color(0xff999999)),
|
||||
),
|
||||
icon: _currentIndex == 2
|
||||
? Image.asset(
|
||||
'images/profile_pressed.png',
|
||||
width: 32.0,
|
||||
height: 28.0,
|
||||
)
|
||||
: Image.asset(
|
||||
'images/profile_normal.png',
|
||||
width: 32.0,
|
||||
height: 28.0,
|
||||
)),
|
||||
],
|
||||
),
|
||||
//中间显示当前页面
|
||||
body: currentPage(),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
//消息类型枚举类型
|
||||
enum MessageType { SYSTEM,PUBLIC,CHAT,GROUP }
|
||||
|
||||
//聊天数据
|
||||
class MessageData{
|
||||
//头像
|
||||
String avatar;
|
||||
//主标题
|
||||
String title;
|
||||
//子标题
|
||||
String subTitle;
|
||||
//消息时间
|
||||
DateTime time;
|
||||
//消息类型
|
||||
MessageType type;
|
||||
|
||||
MessageData(this.avatar,this.title,this.subTitle,this.time,this.type);
|
||||
}
|
||||
|
||||
//组装数据
|
||||
List<MessageData> messageData = [
|
||||
new MessageData('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg',
|
||||
'一休哥',
|
||||
'突然想到的',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403282649&di=c4f237332e6bf94546c950817699c2fd&imgtype=0&src=http%3A%2F%2Fimg5q.duitang.com%2Fuploads%2Fitem%2F201504%2F11%2F20150411H0128_PHr4z.jpeg',
|
||||
'多拉a梦',
|
||||
'机器猫!!!',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403360209&di=ec25c22642ec5e3858dc70a393ca0697&imgtype=0&src=http%3A%2F%2Fphotocdn.sohu.com%2F20110901%2FImg318072437.jpg',
|
||||
'一休哥',
|
||||
'我在思考问题。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403409663&di=dedd3829d437cd3dbaf0eff35843aba6&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F0df3d7ca7bcb0a46e22496026063f6246b60af82.jpg',
|
||||
'忍者神龟',
|
||||
'忍者神龟。。。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403513811&di=9156b412a2d5e15cebe8f3b40a401bb9&imgtype=0&src=http%3A%2F%2Ff.hiphotos.baidu.com%2Fzhidao%2Fwh%253D680%252C800%2Fsign%3D8b8e147a9b529822056631c5effa57f3%2F4afbfbedab64034fb55deabba4c379310b551dfe.jpg',
|
||||
'光头强',
|
||||
'我是光头强。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403568416&di=5ee437e92b9cbc9246035a6353fa8417&imgtype=0&src=http%3A%2F%2Fi6.qhimg.com%2Ft014810bec6c531fc18.jpg',
|
||||
'熊二',
|
||||
'俺是熊二。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403622653&di=35e4ad9d764d3ec3715693cd5508ebdf&imgtype=0&src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20170628%2Fd1b92ad3de7b4078b23b419892ec255e_th.jpg',
|
||||
'超级飞侠',
|
||||
'超级飞侠。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403222736&di=7e55dcf50ed5ff2ad7db1303542aa71b&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3D71f82be767061d957d4637304bf60a5d%2Fdb7d15d8bc3eb135eb03e564af1ea8d3ff1f44a4.jpg',
|
||||
'大耳朵图图',
|
||||
'突然想到的',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403282649&di=c4f237332e6bf94546c950817699c2fd&imgtype=0&src=http%3A%2F%2Fimg5q.duitang.com%2Fuploads%2Fitem%2F201504%2F11%2F20150411H0128_PHr4z.jpeg',
|
||||
'多拉a梦',
|
||||
'机器猫!!!',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403360209&di=ec25c22642ec5e3858dc70a393ca0697&imgtype=0&src=http%3A%2F%2Fphotocdn.sohu.com%2F20110901%2FImg318072437.jpg',
|
||||
'一休哥',
|
||||
'我在思考问题。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403409663&di=dedd3829d437cd3dbaf0eff35843aba6&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F0df3d7ca7bcb0a46e22496026063f6246b60af82.jpg',
|
||||
'忍着神龟',
|
||||
'忍着神龟。。。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403513811&di=9156b412a2d5e15cebe8f3b40a401bb9&imgtype=0&src=http%3A%2F%2Ff.hiphotos.baidu.com%2Fzhidao%2Fwh%253D680%252C800%2Fsign%3D8b8e147a9b529822056631c5effa57f3%2F4afbfbedab64034fb55deabba4c379310b551dfe.jpg',
|
||||
'光头强',
|
||||
'我是光头强。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403568416&di=5ee437e92b9cbc9246035a6353fa8417&imgtype=0&src=http%3A%2F%2Fi6.qhimg.com%2Ft014810bec6c531fc18.jpg',
|
||||
'熊二',
|
||||
'俺是熊二。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
new MessageData(
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403622653&di=35e4ad9d764d3ec3715693cd5508ebdf&imgtype=0&src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20170628%2Fd1b92ad3de7b4078b23b419892ec255e_th.jpg',
|
||||
'超级飞侠',
|
||||
'超级飞侠。。',
|
||||
new DateTime.now(),
|
||||
MessageType.CHAT
|
||||
),
|
||||
];
|
|
@ -0,0 +1,76 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './message_data.dart';
|
||||
import 'package:date_format/date_format.dart';
|
||||
import '../common/touch_callback.dart';
|
||||
|
||||
//聊天信息项
|
||||
class MessageItem extends StatelessWidget{
|
||||
final MessageData message;
|
||||
MessageItem(this.message);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//最外层容器
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
//仅加一个底部边 这样整个列表的每项信息下面都会有一条边
|
||||
border: Border(bottom: BorderSide(width: 0.5,color: Color(0xFFd9d9d9))),
|
||||
),
|
||||
height: 64.0,
|
||||
//按下回调处理 空实现
|
||||
child: TouchCallBack(
|
||||
onPressed: (){
|
||||
},
|
||||
//整体水平方向布局
|
||||
child: Row(
|
||||
//垂直方向居中显示
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
//展示头像
|
||||
Container(
|
||||
//头像左右留一定的外边距
|
||||
margin: const EdgeInsets.only(left: 13.0,right: 13.0),
|
||||
child: Image.network(message.avatar,width: 48.0,height: 48.0,),
|
||||
),
|
||||
Expanded(
|
||||
//主标题和子标题采用垂直布局
|
||||
child: Column(
|
||||
//垂直方向居中对齐
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
//水平方向靠左对齐
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
message.title,
|
||||
style: TextStyle(fontSize: 16.0,color: Color(0xFF353535)),
|
||||
maxLines: 1,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top:8.0),
|
||||
),
|
||||
Text(
|
||||
message.subTitle,
|
||||
style: TextStyle(fontSize: 14.0,color: Color(0xFFa9a9a9)),
|
||||
maxLines: 1,
|
||||
//显示不完的文本用省略号来表示
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
//时间顶部对齐
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
margin: const EdgeInsets.only(right: 12.0,top: 12.0),
|
||||
child: Text(
|
||||
//格式化时间
|
||||
formatDate(message.time, [HH,':',nn,':','ss']).toString(),
|
||||
style: TextStyle(fontSize: 14.0,color: Color(0xFFa9a9a9)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './message_data.dart';
|
||||
import './message_item.dart';
|
||||
|
||||
//聊天主页面
|
||||
class MessagePage extends StatefulWidget{
|
||||
@override
|
||||
MessagePageState createState() => new MessagePageState();
|
||||
}
|
||||
|
||||
class MessagePageState extends State<MessagePage>{
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
//构造列表
|
||||
body: ListView.builder(
|
||||
//传入数据长度
|
||||
itemCount: messageData.length,
|
||||
//构造列表项
|
||||
itemBuilder: (BuildContext context, int index){
|
||||
//传入messageData返回列表项
|
||||
return new MessageItem(messageData[index]);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './touch_callback.dart';
|
||||
|
||||
//通用列表项
|
||||
class ImItem extends StatelessWidget{
|
||||
//标题
|
||||
final String title;
|
||||
//图片路径
|
||||
final String imagePath;
|
||||
//图标
|
||||
final Icon icon;
|
||||
|
||||
ImItem({Key key,@required this.title,this.imagePath,this.icon}):super(key:key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return TouchCallBack(
|
||||
onPressed: (){
|
||||
//判断点击的项
|
||||
switch(title){
|
||||
case '好友动态':
|
||||
//路由到好友动态页面
|
||||
Navigator.pushNamed(context, '/friends');
|
||||
break;
|
||||
case '联系客服':
|
||||
break;
|
||||
}
|
||||
},
|
||||
//展示部分
|
||||
child: Container(
|
||||
height: 50.0,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
//图标或图片
|
||||
Container(
|
||||
child: imagePath != null
|
||||
? Image.asset(
|
||||
imagePath,
|
||||
width: 32.0,
|
||||
height: 32.0,
|
||||
)
|
||||
: SizedBox(
|
||||
height: 32.0,
|
||||
width: 32.0,
|
||||
child: icon,
|
||||
),
|
||||
margin: const EdgeInsets.only(left: 22.0,right: 20.0),
|
||||
),
|
||||
//标题
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 16.0,color: Color(0xFF353535)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
//触摸回调组件
|
||||
class TouchCallBack extends StatefulWidget{
|
||||
//子组件
|
||||
final Widget child;
|
||||
//回调函数
|
||||
final VoidCallback onPressed;
|
||||
final bool isfeed;
|
||||
//背景色
|
||||
final Color background;
|
||||
//传入参数列表
|
||||
TouchCallBack({Key key,
|
||||
@required this.child,
|
||||
@required this.onPressed,
|
||||
this.isfeed:true,
|
||||
this.background:const Color(0xffd8d8d8),
|
||||
}):super(key:key);
|
||||
@override
|
||||
TouchState createState() => TouchState();
|
||||
}
|
||||
|
||||
class TouchState extends State<TouchCallBack>{
|
||||
Color color = Colors.transparent;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//返回GestureDetector对象
|
||||
return GestureDetector(
|
||||
//使用Container容器包裹
|
||||
child: Container(
|
||||
color: color,
|
||||
child: widget.child,
|
||||
),
|
||||
//onTap回调
|
||||
onTap: widget.onPressed,
|
||||
onPanDown: (d){
|
||||
if(widget.isfeed == false) return;
|
||||
setState(() {
|
||||
color = widget.background;
|
||||
});
|
||||
},
|
||||
onPanCancel: (){
|
||||
setState(() {
|
||||
color = Colors.transparent;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './contact_item.dart';
|
||||
|
||||
//好友列表头部
|
||||
class ContactHeader extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: <Widget>[
|
||||
ContactItem(titleName:'新加好友',imageName:'images/icon_addfriend.png'),
|
||||
ContactItem(titleName:'公共聊天室',imageName:'images/icon_groupchat.png'),
|
||||
],);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './contact_vo.dart';
|
||||
|
||||
//好友列表项
|
||||
class ContactItem extends StatelessWidget {
|
||||
//好友数据VO
|
||||
final ContactVO item;
|
||||
//标题名
|
||||
final String titleName;
|
||||
//图片路径
|
||||
final String imageName;
|
||||
//构建方法
|
||||
ContactItem({this.item, this.titleName, this.imageName});
|
||||
|
||||
//渲染好友列表项
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//列表项容器
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
//每条列表项底部加一个边框
|
||||
border:
|
||||
Border(bottom: BorderSide(width: 0.5, color: Color(0xFFd9d9d9))),
|
||||
),
|
||||
height: 52.0,
|
||||
child: FlatButton(
|
||||
onPressed: () {},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
//展示头像或图片
|
||||
imageName == null
|
||||
? Image.network(
|
||||
item.avatarUrl != ''
|
||||
? item.avatarUrl
|
||||
: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg',
|
||||
width: 36.0,
|
||||
height: 36.0,
|
||||
scale: 0.9,
|
||||
)
|
||||
: Image.asset(
|
||||
imageName,
|
||||
width: 36.0,
|
||||
height: 36.0,
|
||||
),
|
||||
//展示名称或标题
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 12.0),
|
||||
child: Text(
|
||||
titleName == null ? item.name ?? '暂时':titleName,
|
||||
style: TextStyle(fontSize: 18.0,color: Color(0xFF353535)),
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import './contact_vo.dart';
|
||||
|
||||
class ContactSiderList extends StatefulWidget {
|
||||
//好友列表项数据
|
||||
final List<ContactVO> items;
|
||||
//好友列表头构造器
|
||||
final IndexedWidgetBuilder headerBuilder;
|
||||
//好友列表项构造器
|
||||
final IndexedWidgetBuilder itemBuilder;
|
||||
//字母构造器
|
||||
final IndexedWidgetBuilder sectionBuilder;
|
||||
|
||||
//构造方法
|
||||
ContactSiderList({
|
||||
Key key,
|
||||
@required this.items,
|
||||
this.headerBuilder,
|
||||
@required this.itemBuilder,
|
||||
@required this.sectionBuilder,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
ContactState createState() => new ContactState();
|
||||
}
|
||||
|
||||
class ContactState extends State<ContactSiderList> {
|
||||
|
||||
//列表滚动控制器
|
||||
final ScrollController _scrollController = new ScrollController();
|
||||
|
||||
bool _onNotification(ScrollNotification notification) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//判断并显示头部视图或空容器
|
||||
_isShowHeaderView(index) {
|
||||
if (index == 0 && widget.headerBuilder != null) {
|
||||
return Offstage(
|
||||
offstage: false,
|
||||
child: widget.headerBuilder(context, index),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
}
|
||||
|
||||
//根据定位判断是否显示好友列表头
|
||||
bool _shouldShowHeader(int position) {
|
||||
if (position <= 0) {
|
||||
return false;
|
||||
}
|
||||
if (position != 0 &&
|
||||
widget.items[position].seationKey !=
|
||||
widget.items[position - 1].seationKey) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//渲染列表
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
//列表加载更多
|
||||
NotificationListener(
|
||||
onNotification: _onNotification,
|
||||
child: ListView.builder(
|
||||
//滚动控制器
|
||||
controller: _scrollController,
|
||||
//list里面的内容不足一屏时,list都可以滑动
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
//列表长度
|
||||
itemCount: widget.items.length,
|
||||
//列表项构造器
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
//列表项容器
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
//显示列表头
|
||||
_isShowHeaderView(index),
|
||||
//用Offstage组件控制是否显示英文字母
|
||||
Offstage(
|
||||
offstage: _shouldShowHeader(index),
|
||||
child: widget.sectionBuilder(context, index),
|
||||
),
|
||||
//显示列表项
|
||||
Column(
|
||||
children: <Widget>[
|
||||
widget.itemBuilder(context, index),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ContactVO {
|
||||
//字母排列值
|
||||
String seationKey;
|
||||
//名称
|
||||
String name;
|
||||
//头像url
|
||||
String avatarUrl;
|
||||
//构造函数
|
||||
ContactVO({@required this.seationKey,this.name,this.avatarUrl});
|
||||
}
|
||||
//好友数据集
|
||||
List<ContactVO> contactData = [
|
||||
new ContactVO(
|
||||
seationKey: 'A',
|
||||
name: 'A张三',
|
||||
avatarUrl: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540633615163&di=e6662df8230b7e8a87cf0017df7252b7&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fac345982b2b7d0a2d1f5b989c0ef76094b369ae2.jpg',
|
||||
),
|
||||
new ContactVO(
|
||||
seationKey: 'A',
|
||||
name: '阿黄',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540441383345&di=39fe0512213122b232a7861363d86ba4&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F8435e5dde71190ef0795a828c41b9d16fcfa60de.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'B',
|
||||
name: '波波',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540441383345&di=41a9c62adb0702595cbeab1eb7935f66&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F3b292df5e0fe992532fd5c7e3fa85edf8db1712e.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'C',
|
||||
name: '陈可',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529317279409&di=c04fca2322c5fd92860d5445ac67f5ba&imgtype=0&src=http%3A%2F%2Fimg.duoziwang.com%2F2018%2F07%2F201812398230049.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'C',
|
||||
name: '参谋长',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540441590992&di=6b6615dbaecc17a83517b8b5bb8853fb&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F34fae6cd7b899e51703453e048a7d933c9950d8f.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'D',
|
||||
name: '杜一',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529317279343&di=a85a9844a259f97a0a3349ad0ca0bdfb&imgtype=0&src=http%3A%2F%2Fpic.qqtn.com%2Fup%2F2017-12%2F2017120617245278991.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'D',
|
||||
name: '东方红',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529317279342&di=7eae385ce6b52688ec1ae23efb6df2b6&imgtype=0&src=http%3A%2F%2Fpic.qqtn.com%2Fup%2F2018-2%2F2018020913274626058.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'D',
|
||||
name: '大表哥',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529317279332&di=4ce7a79c1969de3afd25ff12415a9a86&imgtype=0&src=http%3A%2F%2Fimg.duoziwang.com%2F2018%2F07%2F201812398230061.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'F',
|
||||
name: '飞机',
|
||||
avatarUrl:
|
||||
'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=889175251,2001539136&fm=27&gp=0.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'G',
|
||||
name: '高大上',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529317923619&di=c7c1e8e86f028a98f5f1287f08185dda&imgtype=0&src=http%3A%2F%2Fpic.qqtn.com%2Fup%2F2017-12%2F15131353255776823.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'H',
|
||||
name: 'herbie',
|
||||
avatarUrl:
|
||||
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4174685487,4080018153&fm=11&gp=0.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'H',
|
||||
name: '何小冉',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529318082533&di=12e4f3d6b8bff6da451502fef002c1c1&imgtype=0&src=http%3A%2F%2Fpic.qqtn.com%2Fup%2F2018-6%2F2018060510054743138.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'J',
|
||||
name: '姬如雪',
|
||||
avatarUrl:
|
||||
'http://img5.duitang.com/uploads/item/201609/26/20160926124027_vxRkt.jpeg'),
|
||||
new ContactVO(
|
||||
seationKey: 'J',
|
||||
name: 'JC',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(
|
||||
seationKey: 'J',
|
||||
name: 'JCZ',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(seationKey: 'L', name: '联通', avatarUrl: ''),
|
||||
new ContactVO(
|
||||
seationKey: 'L',
|
||||
name: '留学生',
|
||||
avatarUrl: 'http://www.qqzhi.com/uploadpic/2014-09-25/120539135.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'L',
|
||||
name: '李先森',
|
||||
avatarUrl: 'http://www.qqzhi.com/uploadpic/2015-01-16/110701410.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'L',
|
||||
name: '罗森',
|
||||
avatarUrl: 'http://www.qqzhi.com/uploadpic/2014-10-14/001343706.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'L',
|
||||
name: '老司机',
|
||||
avatarUrl:
|
||||
'http://img.bitscn.com/upimg/allimg/c160107/1452134O464060-32cR.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'L',
|
||||
name: '辣眼睛',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(seationKey: 'M', name: 'Mary', avatarUrl: ''),
|
||||
new ContactVO(
|
||||
seationKey: 'M',
|
||||
name: 'Master',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(seationKey: 'P', name: '彭于晏', avatarUrl: ''),
|
||||
new ContactVO(
|
||||
seationKey: 'P',
|
||||
name: '彭简',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(
|
||||
seationKey: 'Q',
|
||||
name: '乔大',
|
||||
avatarUrl:
|
||||
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2957447029,2344598237&fm=27&gp=0.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'Q',
|
||||
name: '乔小',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529320656524&di=3840b5e429f92459c3a5211c904a74b8&imgtype=0&src=http%3A%2F%2Fimg5.duitang.com%2Fuploads%2Fitem%2F201406%2F29%2F20140629020408_ZtckA.jpeg'),
|
||||
new ContactVO(
|
||||
seationKey: 'Q',
|
||||
name: '邱小玲',
|
||||
avatarUrl:
|
||||
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529320656523&di=afbc5ec78d4a4f28efd20585c0acbdaf&imgtype=0&src=http%3A%2F%2Fcdnq.duitang.com%2Fuploads%2Fitem%2F201502%2F22%2F20150222145005_BGBCX.jpeg'),
|
||||
new ContactVO(
|
||||
seationKey: 'Q',
|
||||
name: '齐东宇',
|
||||
avatarUrl:
|
||||
'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1790389375,489698159&fm=27&gp=0.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'R',
|
||||
name: 'rogerMan',
|
||||
avatarUrl:
|
||||
'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=179495508,198350193&fm=27&gp=0.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'S',
|
||||
name: '石头熊',
|
||||
avatarUrl:
|
||||
'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1811676222,3366694286&fm=27&gp=0.jpg'),
|
||||
new ContactVO(seationKey: 'S', name: '孙丽', avatarUrl: ''),
|
||||
new ContactVO(
|
||||
seationKey: 'S',
|
||||
name: '沈家',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(
|
||||
seationKey: 'T',
|
||||
name: '天天',
|
||||
avatarUrl:
|
||||
'http://img.7139.com/file/201206/4f63c6678cefe6396e0c3d02e52dce47.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'W',
|
||||
name: '薇薇安',
|
||||
avatarUrl:
|
||||
'http://image.bitauto.com/dealer/news/50001912/d140ad9a-5f2d-488d-aa09-7474cb8bc2d0.jpg'),
|
||||
new ContactVO(seationKey: 'X', name: '小猪', avatarUrl: ''),
|
||||
new ContactVO(
|
||||
seationKey: 'X',
|
||||
name: '小猪佩奇',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(
|
||||
seationKey: 'X',
|
||||
name: '茜茜',
|
||||
avatarUrl:
|
||||
'http://dealer2.autoimg.cn/dealerdfs/g23/M10/C3/8E/620x0_1_q87_autohomedealer__wKgFV1hwh4eAY1azAABEQL7nzwY495.jpg'),
|
||||
new ContactVO(
|
||||
seationKey: 'Y',
|
||||
name: '杨洋',
|
||||
avatarUrl:
|
||||
''),
|
||||
new ContactVO(
|
||||
seationKey: 'Z',
|
||||
name: '张一山',
|
||||
avatarUrl:
|
||||
'http://img4.duitang.com/uploads/item/201510/08/20151008222232_rXEve.png'),
|
||||
];
|
|
@ -0,0 +1,56 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import './contact_sider_list.dart';
|
||||
import './contact_item.dart';
|
||||
import './contact_header.dart';
|
||||
import './contact_vo.dart';
|
||||
|
||||
//好友列表主页面
|
||||
class Contacts extends StatefulWidget {
|
||||
@override
|
||||
ContactState createState() => new ContactState();
|
||||
|
||||
}
|
||||
|
||||
class ContactState extends State<Contacts>{
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
//主体实现
|
||||
body: ContactSiderList(
|
||||
//好友列表数据
|
||||
items: contactData,
|
||||
//好友列表头构造器
|
||||
headerBuilder: (BuildContext context, int index){
|
||||
return Container(
|
||||
//好友列表头
|
||||
child: ContactHeader(),
|
||||
);
|
||||
},
|
||||
//好友列表项构造器
|
||||
itemBuilder: (BuildContext context, int index){
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
alignment: Alignment.centerLeft,
|
||||
//好友列表项
|
||||
child: ContactItem(item:contactData[index]),
|
||||
);
|
||||
},
|
||||
//字母构造器
|
||||
sectionBuilder: (BuildContext context, int index){
|
||||
return Container(
|
||||
height: 32.0,
|
||||
padding: const EdgeInsets.only(left:14.0),
|
||||
color: Colors.grey[300],
|
||||
alignment: Alignment.centerLeft,
|
||||
//显示字母
|
||||
child: Text(
|
||||
contactData[index].seationKey,
|
||||
style: TextStyle(fontSize: 14.0,color: Color(0xff909090)),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
//加载页面
|
||||
class LoadingPage extends StatefulWidget {
|
||||
@override
|
||||
_LoadingState createState() => new _LoadingState();
|
||||
}
|
||||
|
||||
class _LoadingState extends State<LoadingPage> {
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
//在加载页面停顿3秒
|
||||
new Future.delayed(Duration(seconds: 3),(){
|
||||
print("Flutter即时通讯APP界面实现....");
|
||||
Navigator.of(context).pushReplacementNamed("app");
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Center(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
//加载页面居中背景图 使用cover模式
|
||||
Image.asset("images/loading.jpeg",fit: BoxFit.cover,),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './app.dart';
|
||||
import './loading.dart';
|
||||
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
|
||||
import './search.dart';
|
||||
|
||||
//应用程序入口
|
||||
void main() => runApp(MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: '聊天室',
|
||||
//自定义主题
|
||||
theme: mDefaultTheme,
|
||||
//添加路由表
|
||||
routes: <String, WidgetBuilder>{
|
||||
"app": (BuildContext context) => new App(),
|
||||
"/friends": (_) => new WebviewScaffold(
|
||||
//Webview插件
|
||||
url: "https://flutter.io/",
|
||||
appBar: new AppBar(
|
||||
title: new Text("Flutter官网"),
|
||||
),
|
||||
withZoom: true,
|
||||
withLocalStorage: true,
|
||||
),
|
||||
'search': (BuildContext context) => new Search(), //搜索页面路由
|
||||
},
|
||||
//指定首页 默认为加载页面
|
||||
home: new LoadingPage(),
|
||||
));
|
||||
|
||||
//自定义主题 绿色小清新风格
|
||||
final ThemeData mDefaultTheme = new ThemeData(
|
||||
primaryColor: Colors.green,
|
||||
scaffoldBackgroundColor: Color(0xFFebebeb),
|
||||
cardColor: Colors.green,
|
||||
);
|
|
@ -0,0 +1,134 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import '../common/touch_callback.dart';
|
||||
import '../common/im_item.dart';
|
||||
|
||||
//我的页面
|
||||
class Personal extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
//列表
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
//头像部分实现
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 20.0),
|
||||
color: Colors.white,
|
||||
height: 80.0,
|
||||
child: TouchCallBack(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
//添加头像
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 12.0, right: 15.0),
|
||||
child: Image.asset(
|
||||
'images/yixiu.jpeg',
|
||||
width: 70.0,
|
||||
height: 70.0,
|
||||
),
|
||||
),
|
||||
//用户名及帐号显示
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'一休',
|
||||
style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
color: Color(0xFF353535),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'帐号 yixiu',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Color(0xFFa9a9a9),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
//二维码图片显示
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 12.0, right: 15.0),
|
||||
child: Image.asset(
|
||||
'images/code.png',
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
//列表项 使用ImItem渲染
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 20.0),
|
||||
color: Colors.white,
|
||||
child: ImItem(
|
||||
title: '好友动态',
|
||||
imagePath: 'images/icon_me_friends.png',
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 20.0),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
ImItem(
|
||||
imagePath: 'images/icon_me_message.png',
|
||||
title: '消息管理',
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15.0, right: 15.0),
|
||||
child: Divider(
|
||||
height: 0.5,
|
||||
color: Color(0xFFd9d9d9),
|
||||
),
|
||||
),
|
||||
ImItem(
|
||||
imagePath: 'images/icon_me_photo.png',
|
||||
title: '我的相册',
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15.0, right: 15.0),
|
||||
child: Divider(
|
||||
height: 0.5,
|
||||
color: Color(0xFFd9d9d9),
|
||||
),
|
||||
),
|
||||
ImItem(
|
||||
imagePath: 'images/icon_me_file.png',
|
||||
title: '我的文件',
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15.0, right: 15.0),
|
||||
child: Divider(
|
||||
height: 0.5,
|
||||
color: Color(0xFFd9d9d9),
|
||||
),
|
||||
),
|
||||
ImItem(
|
||||
imagePath: 'images/icon_me_service.png',
|
||||
title: '联系客服',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 20.0),
|
||||
color: Colors.white,
|
||||
child: ImItem(
|
||||
title: '清理缓存',
|
||||
imagePath: 'images/icon_me_clear.png',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import './common/touch_callback.dart';
|
||||
|
||||
//搜索模块
|
||||
class Search extends StatefulWidget {
|
||||
@override
|
||||
SearchState createState() => new SearchState();
|
||||
}
|
||||
|
||||
class SearchState extends State<Search> {
|
||||
//定义焦点节点
|
||||
FocusNode focusNode = new FocusNode();
|
||||
|
||||
//请求获取焦点
|
||||
_requestFocus() {
|
||||
FocusScope.of(context).requestFocus(focusNode);
|
||||
return focusNode;
|
||||
}
|
||||
|
||||
//返回一个文本组件
|
||||
_getText(String text) {
|
||||
return TouchCallBack(
|
||||
isfeed: false,
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
text,
|
||||
//添加文本样式
|
||||
style: TextStyle(fontSize: 14.0, color: Color(0xff1aad19)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//搜索页面渲染
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
//顶部留一定距离
|
||||
margin: const EdgeInsets.only(top: 25.0),
|
||||
//整体垂直布局
|
||||
child: Column(
|
||||
//水平方向居中
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
//顶部导航栏 包括返回按钮 搜索框及麦克风按钮
|
||||
Stack(
|
||||
children: <Widget>[
|
||||
//使用触摸回调组件
|
||||
TouchCallBack(
|
||||
isfeed: false,
|
||||
onPressed: () {
|
||||
//使用导航器返回上一个页面
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Container(
|
||||
height: 45.0,
|
||||
margin: const EdgeInsets.only(left: 12.0, right: 10.0),
|
||||
//添加返回按钮
|
||||
child: Icon(
|
||||
Icons.chevron_left,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
//搜索框容器
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
height: 45.0,
|
||||
margin: const EdgeInsets.only(left: 50.0, right: 10.0),
|
||||
//搜索框底部边框
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(width: 1.0, color: Colors.green)),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
//输入框
|
||||
child: TextField(
|
||||
//请求获取焦点
|
||||
focusNode: _requestFocus(),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
onChanged: (String text) {},
|
||||
decoration: InputDecoration(
|
||||
hintText: '搜索', border: InputBorder.none),
|
||||
),
|
||||
),
|
||||
//添加麦克风图标
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 10.0),
|
||||
child: Icon(
|
||||
Icons.mic,
|
||||
color: Color(0xffaaaaaa),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 50.0),
|
||||
child: Text(
|
||||
'常用搜索',
|
||||
style: TextStyle(fontSize: 16.0, color: Color(0xffb5b5b5)),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(30.0),
|
||||
child: Row(
|
||||
//对齐方式采用均匀对齐
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
//第一行搜索项
|
||||
children: <Widget>[
|
||||
_getText('朋友'),
|
||||
_getText('聊天'),
|
||||
_getText('群组'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 30.0, right: 30.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
//第二行搜索项
|
||||
_getText('Flutter'),
|
||||
_getText('Dart'),
|
||||
_getText('C++'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
name: wechat
|
||||
description: Flutter即时通讯APP界面实现
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
flutter_webview_plugin: "^0.3.0+2"
|
||||
date_format: "^1.0.4"
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
flutter:
|
||||
|
||||
uses-material-design: true
|
||||
|
||||
assets:
|
||||
|
||||
#加载页面图片资源
|
||||
- images/loading.jpeg
|
||||
|
||||
#底部tab切换图片资源
|
||||
- images/contact_list_normal.png
|
||||
- images/contact_list_pressed.png
|
||||
- images/profile_normal.png
|
||||
- images/profile_pressed.png
|
||||
- images/message_normal.png
|
||||
- images/message_pressed.png
|
||||
|
||||
#菜单按钮
|
||||
- images/icon_menu_addfriend.png
|
||||
- images/icon_menu_group.png
|
||||
|
||||
#好友模块图标
|
||||
- images/icon_addfriend.png
|
||||
- images/icon_groupchat.png
|
||||
- images/icon_public.png
|
||||
|
||||
#我的模块图标
|
||||
- images/icon_me_friends.png
|
||||
- images/icon_me_photo.png
|
||||
- images/icon_me_file.png
|
||||
- images/icon_me_service.png
|
||||
- images/icon_me_message.png
|
||||
- images/icon_me_clear.png
|
||||
- images/code.png
|
||||
- images/yixiu.jpeg
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Welcome to Flutter',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Welcome to Flutter'),
|
||||
),
|
||||
body: Center(
|
||||
child: Text('Hello World'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appName = '自定义主题';
|
||||
|
||||
return new MaterialApp(
|
||||
title: appName,
|
||||
theme: new ThemeData(
|
||||
brightness: Brightness.light,//应用程序整体主题的亮度
|
||||
primaryColor: Colors.lightGreen[600],//App主要部分的背景色
|
||||
accentColor: Colors.orange[600],//前景色(文本、按钮等)
|
||||
),
|
||||
home: new MyHomePage(
|
||||
title: appName,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatelessWidget {
|
||||
final String title;
|
||||
|
||||
MyHomePage({Key key, @required this.title}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text(title),
|
||||
),
|
||||
body: new Center(
|
||||
child: new Container(
|
||||
//获取主题的accentColor
|
||||
color: Theme.of(context).accentColor,
|
||||
child: new Text(
|
||||
'带有背景颜色的文本组件',
|
||||
style: Theme.of(context).textTheme.title,
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: new Theme(
|
||||
//使用copyWith的方式获取accentColor
|
||||
data: Theme.of(context).copyWith(accentColor: Colors.grey),
|
||||
child: new FloatingActionButton(
|
||||
onPressed: null,
|
||||
child: new Icon(Icons.computer),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
//获取天气数据
|
||||
void getWeatherData() async {
|
||||
try {
|
||||
//实例化一个HttpClient对象
|
||||
HttpClient httpClient = new HttpClient();
|
||||
|
||||
//发起请求
|
||||
HttpClientRequest request = await httpClient.getUrl(
|
||||
Uri.parse("http://t.weather.sojson.com/api/weather/city/101030100"));
|
||||
|
||||
//等待服务器返回数据
|
||||
HttpClientResponse response = await request.close();
|
||||
|
||||
//使用utf8.decoder从response里解析数据
|
||||
var result = await response.transform(utf8.decoder).join();
|
||||
//输出响应头
|
||||
print(result);
|
||||
|
||||
//httpClient关闭
|
||||
httpClient.close();
|
||||
|
||||
} catch (e) {
|
||||
print("请求失败:$e");
|
||||
} finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'httpclient请求',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('httpclient请求'),
|
||||
),
|
||||
body: Center(
|
||||
child: RaisedButton(
|
||||
child: Text("获取天气数据"),
|
||||
onPressed: getWeatherData,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'http请求示例',
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text('http请求示例'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new RaisedButton(
|
||||
onPressed: () {
|
||||
|
||||
var url = 'http://httpbin.org/';
|
||||
//向http://httpbin.org/发送get请求
|
||||
http.get(url).then((response) {
|
||||
print("状态: ${response.statusCode}");
|
||||
print("正文: ${response.body}");
|
||||
});
|
||||
|
||||
},
|
||||
child: new Text('发起http请求'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
//MyApp不需要做状态处理,所以此组件继承StatelessWidget即可
|
||||
class MyApp extends StatelessWidget {
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: new ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// Try running your application with "flutter run". You'll see the
|
||||
// application has a blue toolbar. Then, without quitting the app, try
|
||||
// changing the primarySwatch below to Colors.green and then invoke
|
||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
||||
// or press Run > Flutter Hot Reload in IntelliJ). Notice that the
|
||||
// counter didn't reset back to zero; the application is not restarted.
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: new MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//主页需要继承自StatefulWidget
|
||||
class MyHomePage extends StatefulWidget {
|
||||
MyHomePage({Key key, this.title}) : super(key: key);
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
//必需重写createState方法
|
||||
@override
|
||||
_MyHomePageState createState() => new _MyHomePageState();
|
||||
}
|
||||
//状态类必需继承State类,注意后面需要指定为<MyHomePage>
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;//计数器
|
||||
|
||||
void _incrementCounter() {
|
||||
//调用State类里的setState方法来更改状态值,使得计数器加1
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: new Text(widget.title),
|
||||
),
|
||||
body: new Center(
|
||||
// Center is a layout widget. It takes a single child and positions it
|
||||
// in the middle of the parent.
|
||||
child: new Column(
|
||||
// Column is also layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Invoke "debug paint" (press "p" in the console where you ran
|
||||
// "flutter run", or select "Toggle Debug Paint" from the Flutter tool
|
||||
// window in IntelliJ) to see the wireframe for each widget.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
new Text(
|
||||
'$_counter',//绑定计数器的值
|
||||
style: Theme.of(context).textTheme.display1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
onPressed: _incrementCounter,//按下+号按钮调用自增函数
|
||||
tooltip: 'Increment',
|
||||
child: new Icon(Icons.add),
|
||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: '容器组件示例',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('容器组件示例'),
|
||||
),
|
||||
body: Center(
|
||||
//添加容器
|
||||
child: Container(
|
||||
width: 200.0,
|
||||
height: 200.0,
|
||||
//添加边框装饰效果
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
//设置上下左右四个边框样式
|
||||
border: new Border.all(
|
||||
color: Colors.grey, //边框颜色
|
||||
width: 8.0, //边框粗细
|
||||
),
|
||||
borderRadius:
|
||||
const BorderRadius.all(const Radius.circular(8.0)), //边框的弧度
|
||||
),
|
||||
child: Text(
|
||||
'Flutter',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 28.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|