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 也挺好的。

老哥留步,支持一下。

相关推荐
纵有疾風起19 分钟前
C++—string(1):string类的学习与使用
开发语言·c++·经验分享·学习·开源·1024程序员节
Molesidy44 分钟前
【随笔】【QT】QT5.15.2版本的最新下载方式!!!
开发语言·qt
二进制person2 小时前
Java EE初阶 --多线程2
java·开发语言
yue0082 小时前
C#理论学习-WinForm实践开发教程总结
开发语言·学习·c#
007php0073 小时前
某游戏大厂 Java 面试题深度解析(四)
java·开发语言·python·面试·职场和发展·golang·php
Mr.Jessy3 小时前
Web APIs学习第一天:获取 DOM 对象
开发语言·前端·javascript·学习·html
午安~婉3 小时前
javaScript八股问题
开发语言·javascript·原型模式
想不明白的过度思考者3 小时前
Rust——异步递归深度指南:从问题到解决方案
开发语言·后端·rust
西西学代码3 小时前
Flutter---个人信息(5)---持久化存储
java·javascript·flutter
芝麻开门-新起点3 小时前
flutter 生命周期管理:从 Widget 到 State 的完整解析
开发语言·javascript·ecmascript