美文网首页
flutter 分享代码(三)

flutter 分享代码(三)

作者: Victory_886 | 来源:发表于2019-08-03 18:45 被阅读0次
  • 直接代码
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,
      ),
    );
  }
}

相关文章

网友评论

      本文标题:flutter 分享代码(三)

      本文链接:https://www.haomeiwen.com/subject/jmcsdctx.html