02.01 flutter入門項目

本頭條核心宗旨

歡迎來到「技術剛剛好」作者,「技術剛剛好」是個人維護,每天至少更新一篇Flutter技術文章,實時為大家播報Flutter最新消息。如果你剛好也在關注Flutter這門技術,那就跟我一起學習進步吧,你的贊,收藏,轉發是對我個人最大的支持,維護不易,歡迎關注。

技術剛剛好經歷

近幾年,移動端跨平臺開發技術層出不窮,從Facebook家的ReactNative,到阿里家WEEX,前端技術在移動端跨平臺開發中大展身手,技術剛剛好作為一名Android開發,經歷了從Reactjs到Vuejs的不斷學習。而在2018年,我們的主角變成了Flutter,這是Goolge開源的一個移動端跨平臺解決方案,可以快速開發精美的移動App。希望跟大家一起學習,一起進步!

今天我來介紹一個簡單入門的flutter應用,


flutter入門項目

項目結構

main.dart文件

<code>import 'package:flutter/material.dart';

void main() {
runApp(MaterialApp(
// Title
title: "Simple Material App",
// Home
home: Scaffold(
// Appbar
appBar: AppBar(
// Title
title: Text("Simple Material App"),
),
// Body
body: Container(
// Center the content
child: Center(
// Add Text
child: Text("Hello World!"),
),
),
)));
}/<code>

pubspec.yaml文件

<code>name: simple_material_app
description: A new Flutter project.

dependencies:
flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the Icons class.
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/.

# To add assets from package dependencies, first ensure the asset
# is in the lib/ directory of the dependency. Then,
# refer to the asset with a path prefixed with
# `packages/PACKAGE_NAME/`. The `lib/` is implied, do not
# include `lib/` in the asset path.
#
# Here is an example:
#
# assets:
# - packages/PACKAGE_NAME/path/to/asset

# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700/<code>

謝謝觀看技術剛剛好的文章,技術剛剛好是個人維護,每天至少更新一篇Flutter技術文章,實時為大家播報Flutter最新消息。如果你剛好也在關注Flutter這門技術,那就跟我一起學習進步吧,你的贊,收藏,轉發是對我個人最大的支持,維護不易,歡迎關注。


分享到:


相關文章: