赞
踩
import 'package:flutter/material.dart'; void main(){ runApp( MaterialApp( home: Scaffold( appBar: AppBar(title:const Text("你好Flutter")), body:const MyApp(), ), ) ); } class MyApp extends StatelessWidget{ const MyApp({super.key}); @override Widget build(BuildContext context) { return const Center( child: Text("你好Flutter"), ); } }
import 'package:flutter/material.dart'; void main(){ runApp( MaterialApp( home: Scaffold( appBar: AppBar(title:const Text("你好Flutter")), body:Column( children: const[ MyApp(), MyButton(), MyText() ] ) ), ) ); } class MyApp extends StatelessWidget{ const MyApp({super.key}); @override Widget build(BuildContext context) { return Center( child: Container( margin:const EdgeInsets.fromLTRB(0, 60, 0, 0), alignment: Alignment.center, //配置Container 容器内元素位置的方法 height: 200, width: 200, // transform: Matrix4.translationValues(10,0,0), //位移 // transform: Matrix4.rotationZ(0.2), //延左上角旋转 transform: Matrix4.skewY(0.2), //倾斜 decoration: BoxDecoration( color: Colors.yellow, //背景颜色 border:Border.all( //边框 color: Colors.red, width: 2 ), borderRadius: BorderRadius.circular(10), //配置圆角 也可以实现圆形 100 boxShadow:const [ //配置阴影效果 BoxShadow( color: Colors.blue, blurRadius: 20.0 ) ], //LinearGradient 线性渐变 RadialGradient 径向渐变 gradient: const LinearGradient( colors:[ Colors.red,Colors.yellow ] ) ), child: const Text("你好Flutter",style: TextStyle( color: Colors.black, fontSize: 20, ),), ), ); } } class MyButton extends StatelessWidget{ const MyButton({super.key}); @override Widget build(BuildContext context) { return Container( alignment: Alignment.center, width: 200, height: 40, // margin:const EdgeInsets.all(10), margin: const EdgeInsets.fromLTRB(0, 20, 0, 0), // padding: const EdgeInsets.fromLTRB(40,0,0,0), decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(20) ), child: const Text("按钮",style: TextStyle( color: Colors.white, fontSize: 20 ), ), ); } } class MyText extends StatelessWidget{ const MyText({super.key}); @override Widget build(BuildContext context) { return Container( width: 200, height: 200, margin: const EdgeInsets.fromLTRB(0, 50, 0, 0), decoration: const BoxDecoration( color: Colors.yellow ), child:const Text("你好我是Flutter你好我是Flutter你好我是Flutter你好我是Flutter", textAlign: TextAlign.right, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w900, color: Colors.red, fontStyle: FontStyle.italic, letterSpacing: 1, decoration: TextDecoration.underline, decorationColor: Colors.black, decorationStyle: TextDecorationStyle.dashed ), ), ); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。