text
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title:'Flutter' ,
home: Scaffold(
appBar: AppBar(
title: Text('欢迎来到Fultter'),
),
body: Center(
child: Text(
'Hello Widget!,我是 Antipa,我非常喜欢编程,我想弄懂互联网背后的秘密,我希望我能一直走下去,加油! ',
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style:TextStyle(
fontSize: 25.0,
color: Color.fromARGB(255, 255, 125, 125),
decoration: TextDecoration.underline,
decorationStyle: TextDecorationStyle.solid,
),
),
),
),
);
}
}
container
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title:'Flutter' ,
home: Scaffold(
appBar: AppBar(
title: Text('欢迎来到Fultter'),
),
body: Center(
child: Container(
child: new Text('Hello Antipas',style: TextStyle(fontSize: 40.0),),
alignment: Alignment.center, // 居中对齐 centerleft centerright
// alignment: Alignment.bottomCenter, // 下对齐 bottomLeft bottomright
width: 500.0,
height: 400.0,
color: Colors.blueAccent,
),
),
),
);
}
}
padding margin decoration
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title:'Flutter' ,
home: Scaffold(
appBar: AppBar(
title: Text('欢迎来到Fultter'),
),
body: Center(
child: Container(
child: new Text('Hello Antipas',style: TextStyle(fontSize: 40.0),),
// alignment: Alignment.center, // 居中对齐 centerleft centerright
// alignment: Alignment.bottomCenter, // 下对齐 bottomLeft bottomright
alignment: Alignment.topLeft,
width: 500.0,
height: 400.0,
// color: Colors.blueAccent,
// padding: const EdgeInsets.all(15.0), //内边距
padding: const EdgeInsets.fromLTRB(10.0,20.0,0.0,0.0),
margin: const EdgeInsets.all(18.0), // 外边距
decoration: new BoxDecoration( // 背景颜色
gradient: const LinearGradient(
colors: [Colors.lightBlue,Colors.greenAccent,Colors.purple]
),
border: Border.all(width: 10.0,color: Colors.green) // 外边框
),
),
),
),
);
}
}
image fit repeat 图片
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title:'Flutter' ,
home: Scaffold(
appBar: AppBar(
title: Text('欢迎来到Fultter'),
),
body: Center(
child: Container(
child: new Image.network( //asset file memory network
'https://image.sitapix.com/sourcefile/sitapix-photo-2941087-via-sitapix-com.jpeg@!index-thumb',
// fit 图片和容器关系
// fit: BoxFit.contain,
// contain保持原图比例
// cover
// fill整个图片将容器填满
// fitHeight
// fitWidth 横向为首充满容器
// none 填充容器
// fit: BoxFit.cover,
// repeat 重复图片(以中间图片为中心)
repeat: ImageRepeat.repeat, // repeatX repeatY
),
width: 300.0,
height: 200.0,
color: Colors.lightBlue,
),
),
),
);
}
}
ListView image icon
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title: 'Test for Flutter',
home: Scaffold(
appBar: new AppBar(title: new Text('ListView Widget---')),
body: new ListView(
children: <Widget>[
new ListTile(
leading: new Icon(Icons.adb),
title: new Text('adb'),
),
new ListTile(
leading: new Icon(Icons.airport_shuttle),
title: new Text('airport_shuttle'),
),
new ListTile(
leading: new Icon(Icons.adjust),
title: new Text('adjust'),
),
new ListTile(
leading: new Icon(Icons.adjust),
),
new Image.network('https://www.sitapix.com/2019/10/25/sitapix-photo-3052307.html'),
new Image.network('https://www.sitapix.com/2019/10/25/sitapix-photo-2962201.html'),
// new Image.network('https://www.sitapix.com/2019/10/25/sitapix-photo-2083146.html'),
// new Image.network('https://www.sitapix.com/2019/10/25/sitapix-photo-2990610.html'),
// new Image.network('https://www.sitapix.com/2019/10/24/sitapix-photo-931180.html'),
],
),
),
);
}
}
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title: 'Test for Flutter',
home: Scaffold(
appBar: new AppBar(title: new Text('ListView Widget---')),
body: Center(
child: Container(
height: 200.0,
child: new ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
new Container(
width: 180.0,
color: Colors.cyanAccent,
),
new Container(
width: 180.0,
color: Colors.pink,
),
new Container(
width: 180.0,
color: Colors.blue,
),
new Container(
width: 180.0,
color: Colors.deepOrange,
),
],
),
),
),
),
);
}
}