添加源码文件

This commit is contained in:
18871002288 2019-01-23 13:54:42 +08:00
parent a3d0306141
commit 6278a9b406
237 changed files with 7946 additions and 0 deletions

View File

@ -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}'),
),
);
}
}

View File

@ -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('返回页面'),
),
),
);
}
}

View File

@ -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'),
),
),
],
),
),
);
}
}

View File

@ -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,
),
),
),
),
),
);
}
}

View File

@ -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;
}
}

View File

@ -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,
),
),
),
),
),
);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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(),
),
);
}

View File

@ -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(),
),
);
}

View File

@ -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(),
),
);
}

View File

@ -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(),
),
);
}

View File

@ -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(),
),
);
}

View File

@ -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(),
),
);
}

View File

@ -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),
),
),
),
),
);
}
}

View File

@ -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.01.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),
),
);
}
}

View File

@ -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);
},
),
);
}
}

View File

@ -0,0 +1,8 @@
.DS_Store
.dart_tool/
.packages
.pub/
pubspec.lock
build/

View File

@ -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>

View File

@ -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>

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="Flutter Plugins" type="FlutterPluginsLibraryType">
<CLASSES>
<root url="file://$PROJECT_DIR$" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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="&lt;template&gt;" 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="&lt;template&gt;" 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="&lt;template&gt;" 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&#9;" 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>

View File

@ -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

View File

@ -0,0 +1,3 @@
## 0.0.1
* TODO: Describe initial release.

View File

@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures

View File

@ -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'
}
}

View File

@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536M

View File

@ -0,0 +1 @@
rootProject.name = 'flutter_plugin_demo'

View File

@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="demo.com.flutterplugindemo">
</manifest>

View File

@ -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();
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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'),
),
),
);
}
}

View File

@ -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

View File

@ -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,
);
});
}

View File

@ -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>

View File

@ -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

View File

@ -0,0 +1,4 @@
#import <Flutter/Flutter.h>
@interface FlutterPluginDemoPlugin : NSObject<FlutterPlugin>
@end

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -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(),
);
}
}

View File

@ -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
),
];

View File

@ -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)),
),
),
],
),
),
);
}
}

View File

@ -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]);
}
),
);
}
}

View File

@ -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)),
),
],
),
),
);
}
}

View File

@ -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;
});
},
);
}
}

View File

@ -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'),
],);
}
}

View File

@ -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,
),
),
],
),
),
);
}
}

View File

@ -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),
],
),
],
),
);
}),
),
],
),
);
}
}

View File

@ -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'),
];

View File

@ -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)),
),
);
},
),
);
}
}

View File

@ -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,),
],
),
);
}
}

View File

@ -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,
);

View File

@ -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',
),
),
],
),
);
}
}

View File

@ -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++'),
],
),
),
],
),
),
);
}
}

View File

@ -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

View File

@ -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'),
),
),
);
}
}

View File

@ -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),
),
),
);
}
}

View File

@ -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,
),
),
),
);
}
}

View File

@ -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请求'),
),
),
),
);
}
}

View File

@ -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.
);
}
}

View File

@ -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),
),
),
),
),
);
}
}

Some files were not shown because too many files have changed in this diff Show More