class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Demo"),
),
body: Center(
child: MyDecoratedBox(),
),
);
}
}
/// 美化一个按钮Demo
class MyDecoratedBox extends StatefulWidget {
MyDecoratedBox({Key key}) : super(key: key);
My_DecoratedBoxState createState() => My_DecoratedBoxState();
}
class My_DecoratedBoxState extends State<MyDecoratedBox> {
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
gradient:
LinearGradient(colors: [Colors.red, Colors.blue, Colors.green]),
borderRadius: BorderRadius.all(Radius.circular(5.0)),
boxShadow: [
BoxShadow(
color: Colors.black,
offset: Offset(3, 3),
blurRadius: 5.0,
),
],
),
child: FlatButton(
child: Text(" 登 录 "),
onPressed: null,
),
);
}
}
网友评论