eg:
image.png
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:photo_view/photo_view.dart';
import 'package:oktoast/oktoast.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return OKToast(
/// set toast style, optional
child: MaterialApp(
title: 'Flutter Demo',
theme: 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 simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.lightBlue,
),
home: BasicDemo(),
));
}
}
class BasicDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
//脚手架
appBar: AppBar(
title: Text('viewPager demo'),
centerTitle: true,
backgroundColor: Colors.white,
elevation: 5,
//阴影
toolbarOpacity: 0.6, //透明度
),
backgroundColor: Colors.grey,
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add, color: Colors.red, size: 40),
elevation: 10,
highlightElevation: 5,
//长按提示
tooltip: "1233",
backgroundColor: Colors.white,
onPressed: () {
showToast("123", position: ToastPosition.bottom);
},
),
body: container_test,
);
}
}
var row_test = Row(
children: [Text("1"), Text("2"), Text("3"), Text("4")],
);
var row_column = Column(
children: [Text("1"), Text("2"), Text("3"), Text("4")],
crossAxisAlignment: CrossAxisAlignment.start,
);
var row_expanded = Row(
children: [
Expanded(child: Text("data1data1data1data1data1data1data1")),
Expanded(child: Text("data2")),
Expanded(child: Text("data3")),
],
);
List<int> list = [1, 2, 3, 4, 5, 6, 7, 8];
var container_test = Container(
padding: EdgeInsets.all(40),
margin: EdgeInsets.fromLTRB(10, 10, 10, 20),
color: Colors.cyan,
child: new Column(
children: [
new Icon(
Icons.transfer_within_a_station,
color: Colors.yellow,
),
new Text(
"车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强车育强",
textAlign: TextAlign.left,
),
new Stack(children: [
Container(
width: 100,
height: 100,
color: Colors.red,
),
Container(
width: 90,
height: 90,
color: Colors.blue,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
Text("data"),
Text("data1"),
Text("data111"),
Align(
heightFactor: 3,
alignment: Alignment.topRight,
// widthFactor: 2,
// heightFactor: 2,
// alignment: Alignment(3.0, 3.0),
child: Card(
margin: EdgeInsets.all(10),
elevation: 30,
color: Color(0xffffffff),
child: Text('东南幽恨满词笺。')),
)
]),
new Expanded(
child: CarouselSlider(
options: CarouselOptions(height: 200),
items: list
.map((item) => Container(
child: Center(child: Text(item.toString())),
color: Colors.red,
))
.toList())),
new Expanded(
child: PhotoView(
backgroundDecoration: null,
imageProvider: AssetImage("assets/small-image.jpg"),
)),
new Expanded(
child: new Text(
"你好\n,陈家\n达.",
textAlign: TextAlign.center,
maxLines: 3,
),
),
row_test,
row_column,
row_expanded,
],
crossAxisAlignment: CrossAxisAlignment.stretch,
),
);
网友评论