flutter 写个简单的界面

起因, 目的:

来源: 客户需求。 着急要,我随便写的,应付一下。

过程:

略,直接看代码,看注释。

代码 1 xxx
java 复制代码
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

// #
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',

      // 隐藏调试模式横幅
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),

      home: TicTacToeHomePage(), // title: 'Flutter Demo Home Page'
    );
  }
}

// 这部分就是一个占位的。  是个初步版本。
// TicTacToeHomePage
// class TicTacToeHomePage extends StatelessWidget {
//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       appBar: AppBar(
//         title: Text('Tic Tac Toe'),
//       ),
//       body: Center(
//         child: Text('hey!!!'),
//       ),
//     );
//   }
// }

class TicTacToeHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Row(
          children: <Widget>[
            Image(
              image: AssetImage('assets/images/face.jpg'), // 替换为你的图片路径
              width: 30.0, // Image style
            ),

            SizedBox(width: 10.0), // 间距

            Text('123456 someone@who',
                style: TextStyle(
                    fontWeight: FontWeight.bold, fontSize: 20.0)), // Text style
          ],
        ),
        backgroundColor: Colors.blue, // AppBar style
      ),

      // body: Center(
      //   child: Text('hey!!!'),
      // ),

      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Welcome to the game Tic Tac Toe',
                style: TextStyle(
                    fontSize: 24.0,
                    color: Colors.orange,
                    fontWeight: FontWeight.bold)),
            // Welcome message with styles
            SizedBox(height: 20.0),
            // 间距
            Image(
              image: AssetImage('assets/images/game_img.jpg'), // 替换为你的图片路径
              width: 300.0, // Image style
            ),
            SizedBox(height: 20.0),
            // 间距
            ElevatedButton(
              style: ElevatedButton.styleFrom(
                backgroundColor: Colors.red, // 按钮背景颜色
                foregroundColor: Colors.white, // 按钮前景色
                padding: EdgeInsets.symmetric(
                    vertical: 10.0, horizontal: 20.0), // 按钮内边距
              ),
              child: Text('Start Game', style: TextStyle(fontSize: 18.0)),
              // Button text style
              onPressed: () {
                print('Key pressed!');
              },
            ),
          ],
        ),
      ),
    );
  }
}

效果图

结论 + todo

  • 最近写的这个几个 flutter:
  • 前面2篇,是用 vscode 写的
  • 这次是用的是 andriod studio,环境配置差不多用了1个小时。
  • andriod studio 很久不用,各种更新。 其实,andriod studio 也挺好的。

老哥留步,支持一下。

相关推荐
神仙别闹几秒前
基于Python+Neo4j实现新冠信息挖掘系统
开发语言·python·neo4j
前端太佬2 分钟前
微信小程序支付全流程实战指南(Node.js后端篇)
前端·javascript·微信小程序
资深前端外卖员6 分钟前
【nodejs高可用】Nodejs应用安全防范的问题总结
前端·javascript
前端大白话16 分钟前
Vue2和Vue3语法糖差异大揭秘:一文读懂,开发不纠结!
javascript·vue.js·设计模式
tianchang18 分钟前
JS 中 Map 的概念与使用
前端·javascript
Jenlybein18 分钟前
[ Javascript 面试题 ]:提取对应的信息,并给其赋予一个颜色,保持幂等性
前端·javascript·面试
Carlos_sam18 分钟前
Opnelayers:向某个方向平移指定的距离
前端·javascript
St22 分钟前
探索JavaScript原型链设计——详解prototype、__proto__及constructor三者之间的关系
前端·javascript
前端大白话22 分钟前
JavaScript中`Symbol.for()`和`Symbol()`的区别,在创建全局唯一的`Symbol`值时如何选择使用?
前端·javascript·设计模式