northpaddyのブログ

日々学んだプログラミングについてアウトプットしていきます

Flutterデモアプリをカスタマイズしてみよう④

概要

Flutterデモアプリを少しずつ弄っていってFlutterに慣れていくのが目的です

前回の記事はこちら

前回までのコードは以下のようになっています

今回行うこと

今回は前回の続きで画面遷移の実装を行なっていきます

  • 新しいファイルの作成
  • classの作成
  • Scaffoldの中身の記述
  • main.dartに遷移したいファイルを記述
  • next_pageからmainに戻る記述

dartファイルの作成

遷移後のページのファイルを作る為、新しいdartファイルを作っていきます。
https://i.gyazo.com/90b536c016fddb2940ca575a9680514c.png

Androidstudioのファイル一覧でファイルを作りたいところで左クリックを押し、
new→Dart Fileを選択します。
今回はlibフォルダー内にファイルを作成していきます
f:id:paddy_north:20201117233914j:plain
ファイル名は適当にnext_pageにします
(スネークケースでの命名になります)

https://i.gyazo.com/289e4d0a8ec13aca5151d5c4fe7b065b.png
next.page.dartというファイルが出来ました!

Next_pageのclass

新しいファイルが出来たら新たに記述をしていきます

まずはclassを作っていきます

class NextPage extends StatelessWidget {
}

と記述します
一番上にcupertinoがimportされているという記述が自動生成されるので
materialに変更しておきます
https://i.gyazo.com/df6141f6e7e7f132d13b380a25faf5f7.png
↓
https://i.gyazo.com/4c05d41cb78f597ba4c01463def70cef.png


NextPageに赤波線が出ると思います
https://i.gyazo.com/a6ea65c7fa4f23b6a38cf6301825f4ab.png
その上でクリック押すと、赤い電球が出てきます
https://i.gyazo.com/c40d8ddea4cbb85104a7dbb740ecbeba.png
それをクリックし、Create 1 missing override(s)をクリックします
すると以下のような記述が自動生成されました
https://i.gyazo.com/b9af7426fe241f20a32c9485df6bfc70.png
中のTODO…とthrow…はいらないので削除しておきます

Next_pageのscaffold

scaffoldの中身を書いていきます

AppBar

まずはmainページと同様にAppBarを作成していきます
main.dartのAppBarの部分を参考にそのままコピーします
遷移先だとわかるように以下の変更を加えました

class NextPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("次のページ"), //変更
          actions: [
            Icon(Icons.adb_outlined), //変更
          ],
        ),

body

次にbodyを実装していきます
今回は分かりやすく、背景の色を変えていきましょう

・bodyにContainerと指定して、背景に色をつけます
・画面の真ん中にTextも表示させてみます
・今回はさらにTextのstyleも変更してみます

      body: Container(
        color: Colors.red, //背景色
        child: Center(
            child: Column(mainAxisSize: MainAxisSize.min,
                children: [
                  Text('遷移しましたっ!',
                      style: TextStyle( //この中にstyleを記述
                        fontSize: 30, //サイズ
                        fontWeight: FontWeight.bold, //文字の太さ 
                      )),
        ])),
      ),

floatingActionButton

floatingActionButtonを戻るボタンとして活用します
「→」アイコンではおかしいので「←」アイコンに変更します

      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_back), //アイコン変更
        onPressed: () {
        },
      ),

nextpageの準備が整いました。
この時点では確認出来ないので次に進みます

いよいよ次が遷移の記述です

遷移の仕方

遷移の仕方のは2種類の方法があるようです

・あらかじめroutesに登録しておく方法
・必要に応じてroutesを指定し、登録しておく方法

どちらでも良いんですが
今回は下のroutesを必要に応じて登録していく方をやっていきます

遷移についての考え方で2つのキーワードがあります。
それはpushとpopです

私の解釈で簡単に言えば
pushは進む
popは戻る
厳密に違うかもしれませんがこう覚えておきます笑

ではまずmain.dartに記述していきます
ボタンを押した時に反応して欲しいのでonPressedの中に記述します

      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_forward),
        onPressed: () {
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => NextPage()), //NextPageを指定
          );
        },
      ),

これで遷移してくれます
ホットリロードして試してみます
https://i.gyazo.com/7b8bcd4affe45a3a5840f3443390f4d0.gif
遷移しました!!
しかし、今の時点で戻るボタンは反応しません
戻るボタンを実装しましょう

next_page.dartに記述します
これもonPressedの中に記述します

      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_back),
        onPressed: () {
          Navigator.pop(context); //追記
        },
      ),

では試してみます
https://i.gyazo.com/1414635a723c4a96a47992a6b2bb2f60.gif
戻るボタンも反応してくれました!!

まとめ

今回は遷移を実装しました
ページ遷移はほぼ必ず必要になるのでマスターしていきたいですね!

最後まで読んで下さってありがとうございました!

Flutterデモアプリをカスタマイズしてみよう③

概要

Flutterデモアプリを少しずつ弄っていってFlutterに慣れていくのが目的です

前回の記事はこちら
前回までのアプリの様子
https://i.gyazo.com/1ba9876b91f3e23624948a7c0a06406b.png

前回までのコードは以下のようになっています

今回行うこと

今回と次回で画面遷移を行ってみたいと思います
その為にレイアウトを整えつつ、画面遷移を行えるようにしていきます

まずはレイアウトをきれいにする為準備を行なっていきます

準備

まず前回行なった背景色をデフォルトに戻し、テキストの下にボタンを作れるように準備していきます

  • bodyのcontainerをCenterに変更
    • Colorは削除
  • CenterのchildにColumnを追加
  • Columnの中にmainAxisSizeを追加します
    • mainAxisSizeとはColumnやRowの余分な領域を消してくれます
  • Columnに複数Widgetを追加したいのでchildrenに変更

ここまでのコードを確認

      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'ボタンを押した回数は  ',
                ),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.headline4,
                ),
                Text(
                  '  回',
                ),
              ],
            ),

ボタン配置

Flutterには色々なボタンが用意されていますが
今回は「RaiseButton」という立体的なボタンを作っていきます
上記のコードの下に以下のコード入力していきます

             RaisedButton(
              child: Text('ボタン'),
            ),

ホットリロード
https://i.gyazo.com/df1c206151a6930f5893abcd4ca41258.png
ボタンが追加されましたが、押しても反応がありません
ここで「onPressed」というプロパティを使います
これはfloatingActionButtonの方にもあります!
記述します

             RaisedButton(
              child: Text('ボタン'),
              onPressed: (){
              },
            ),

ホットリロードするとボタンが反応してくれました!
https://i.gyazo.com/049883d2021093c8aee48421077b0ee6.gif

ボタンのカスタマイズ

ここでは先ほど記述したボタンをカスタマイズしていきます

色

ボタンの色は前回もやったColorで変更していきます

文字の色

文字の色はtextColorで変更します

形状の変更

ボタンの形状の変更にはshapeというのを用います
今回は角丸ボタンにしてみます

以上のものを記述していきます

             RaisedButton(
              child: Text('ボタン'),
              color: Colors.blue,
              textColor: Colors.white,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(10),
              ),
              onPressed: (){
              },
            ),

ホットリロード
https://i.gyazo.com/b4fab031c48c66fbe626fca32494fac0.png
良い感じのボタンができました!

カウントアップボタンの変更

新たにボタンができましたが
今回作ったボタンをカウントアップのボタンにした方が
分かりやすそうです!
その辺も変更していきます!

floatingActionButtonの方の_incrementCounterをRaisedButtonに持ってきます

             RaisedButton(
              child: Text('ボタン'),
              color: Colors.blue,
              textColor: Colors.white,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(10),
              ),
              onPressed: _incrementCounter, //追記
            ),
          ]
        ),
      ),
      floatingActionButton: FloatingActionButton(
        // onPressed: _incrementCounter, //コメントアウト
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),

https://i.gyazo.com/3db1f4da901f2fa6edbc6d41ef01c6fb.gif
ボタンを押したらカウントアップするようになりました!

遷移ボタンをfloatingActionButtonに変更する

カウントアップボタンの変更が終わったので
floatingActionButtonを遷移する際のボタンとして変更していきます
ここでは分かりやすいようにアイコンで表現してみたいと思います

onPressed

コメントアウトを解除し、中身を空にする

icon

アイコンをarrow_forwardに変更する

tooltip

tooltipは長押した際などに表示されるものなのでここではコメントアウトしておきます

以上のものを記述していきます

      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_forward),
        onPressed: () {
          // tooltip: 'Increment', //コメントアウト
        },
      ),

これで遷移ボタンの準備が出来ました!

まとめ

ここまでで画面遷移までのある程度の準備が出来ましたので
次回画面遷移の続きをやっていきたいと思います。

Flutterデモアプリをカスタマイズしてみよう②

概要

Flutterデモアプリを少しずつ弄っていってFlutterに慣れていくのが目的です

前回の記事はこちら
前回までのアプリの様子
https://i.gyazo.com/cb023475d6cdc662794afe728ff8ec9c.png
前回までのコードは以下のようになっています


bodyの中身を変更してみる

前回はAppBarの中身を弄ってみました

今回は body: Centerと書かれている以下の記述を変えていきます

      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),

まずbodyとはアプリの中身の部分だと推測されます
それをCenter、真ん中に表示させているようです
真ん中に表示させている子要素にColumnで表示させている

『Column』とは列方向、縦に並べるという事
また、横方向に並べる『Row』があります

試しにCenterをRowに変更してみます

      body: Center(
        child: Row( //Rowに変更
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),

https://i.gyazo.com/b17e08cbf0199812d57e7cc5db8c02ed.png
テキストが横方向に並んだのが分かります

Columnでもいいのですがせっかくなのでそのままにして
テキストの方を日本語にしてさらに追加要素を加えて整えていきます

      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'ボタンを押した回数は ',  //変更
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            Text( //追加
              ' 回', //追加
            ),
          ],
        ),
      ),

ホットリロードしてみます
https://i.gyazo.com/6f062b486a7b42f456326f367e6f1a93.png
いい感じの表示になりました!

装飾

次はbody内の文字の色を変えたり、
背景位の色を変えたりして遊んでいきたいと思います

ではまずbodyのCenterの上でalt+enterを押してみます
すると以下のような項目が出てきたと思います
https://i.gyazo.com/31d5830374e2b9b031e7eddb25dbeebe.png
その中の「Wrap with Container」を選んでみます

すると以下のような記述に変更しました
https://i.gyazo.com/93f1763ab70172aa12900582e4d46868.png
bodyがContainerに変更され
child:にCenterという記述が追加されました

Containerとは要は箱が出来たという事です
bodyに箱が出来たという解釈でいいと思います笑

このように箱にするとその中に色の指定が出来たりするようになります

早速色を変えてみましょう
Containerに色を指定していきます

      body: Container(
        color: Colors.green,
        child: Center(

https://i.gyazo.com/7d703f19e1a51c197eb5ac15193b5c71.png
色の変更ができました!
しかし、ちょっと濃すぎるのでもう少し薄くしてみたいと思います
geernの後に[ ]を追加し200と入れてみます

      body: Container(
        color: Colors.green[200],
        child: Center(

https://i.gyazo.com/ddead41bbfa6a98fe500ee8ecfa5bcac.png
薄くなりました!

whiteの方が良いんですけど今回は変化を楽しみたいので
このままにしておきます笑

まとめ

今回は

  • 文字の表示方向
  • Containerを作って色をつける

というのをやってみました!

色々弄ってホットリロードで変化するのが楽しすぎます!
次回ももっと弄っていきます!

Flutterデモアプリをカスタマイズしてみよう①

概要

Flutterデモアプリを少しずつ弄っていってFlutterに慣れていくのが目的です

前回のデモアプリ立ち上げの状態のコードはこちら

コメントの削除

今回はまずコメントを削除してスッキリさせます

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

これでスッキリしました

では今のデモアプリ状態を見てみましょう
https://i.gyazo.com/91ffcd90046ff8b754a39b8dffff227d.png
こんな感じになってます

コードを詳しく見てみよう

このコードのどこがどこに対応しているのか見てみましょう
Flutter inspectorを開いてみてみます
https://i.gyazo.com/cf40df1061110338ec6874e8005676ff.png
このコードはこのように構成されていることがわかります
その中のscaffoldの中に注目してみましょう

  • Centerの中にColumnとTextとText(センターにColumnで表示されたTextとTextがある)
  • AppBarの中にText(AppBarにTextが表示されている)
  • FloatingActionButtonの中にIcon(FloatingActionButtonにIconの+が表示されている)

どうやらこの辺が表示関連に関わっていそうです

日本語に直してみよう

表示関連の場所が特定できたのでちょっと弄ってみましょう

現在デモアプリに表示されている文字は
英語で僕たち日本人には読めません!(キッパリ)

では日本語に直していきましょう
ではまず”Flutter Demo Home Page”を日本語にしていきます
先ほどのscaffoldの中のAppBarの中を見てみます

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),

Textの中に(widget.title)とあります
これは上の方にある

   home: MyHomePage(title: 'Flutter Demo Home Page'),

ここからwidget.titleとして呼び出されているようです

どちらを変更してもタイトルは変えられますが
AppBarの方を直接変えてみます

   title: Text("フラッターデモホームページ"),

変更しました!
ホットリロードを使って反映された事を確認します
command+sを押すか、⚡︎マークボタンを押します
するとホットリロードが実行されます
https://i.gyazo.com/1513d0dd23d9a04567c0683ca6a51671.png

AppBarの文字が”フラッターデモホームページ”に変更されました!

アイコンを追加してみる

文字を日本語にすることが出来たので
今度はAppBarにさらにアイコンを追加してみます
title: Text("フラッターデモホームページ"),で改行し、
actions: []と記述します
[ ]の間で改行しIcon(Icons.),と記述します

flutterで用意されているのか
アイコンは無数に用意されています笑
Icons.と入力すると候補がたくさん出てきます

適当に選んでみましょう!

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("フラッターデモホームページ"),
        actions: [ //追記
          Icon(Icons.adb_outlined), //追記
        ],

適当にadb_outlinedを選んでみました
それではホットリロードを実行してみます
https://i.gyazo.com/cb023475d6cdc662794afe728ff8ec9c.png
右端にアイコンが追加されました!!

まとめ

今回はAppBarの中を変更してみました
まだまだ理解は出来ていないところもありますがアウトプット頑張ります

Flutterデモアプリを立ち上げてみた

概要

この記事では最近個人的興味のあるFlutterについて
アウトプットしていきます

Flutter Projectを立ち上げる

flutterの環境構築が終わり、Android Studioでflutterが使えるようになりました!!
https://i.gyazo.com/eb0edd1710b0e19f0202aa49accdc612.png
”Create New Flutter Project”をクリックし、
新しいプロジェクトを立ち上げてみましょう!!

立ち上げ準備

Create New Flutter Projectをクリックした後
以下の表示が現れます
https://i.gyazo.com/e5f0091a260b6a0ebbb2a7690dd1a891.png
Flutter Applicationを選択します

次にアプリケーションの名前を記入します
f:id:paddy_north:20201109194200j:plain
好きな名前をつけてみましょう!

次はPackage nameをつけます
https://i.gyazo.com/f3a004e41086b8ba0154a587cfd0fcac.png
例として
flutterapp.example.comではなく
com.example.flutterappというように記入するようにしましょう

Finishを押して準備完了です!

main.dart

新しくFlutterプロジェクトを立ち上げると
main.dartの中身が表示されていると思います
あらかじめ用意されているデモアプリのコードが表示されます

以下がそのコードになります

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

何やら色々と書いてありますね😅
とりあえずエミュレーター 、シミュレーターを立ち上げてアプリを起動してみます

立ち上げ方はコード内のコメントにこう書いてあります

//Try running your application with "flutter run". 

何やらflutter runを実行してみよ。とのことです
ターミナルにてflutter runを実行してみます
https://i.gyazo.com/c5f6ca1ac8bbd0b365c5093df4054e8e.png

立ち上がりました!!
画像は左がAndroid、右がiOSでの様子です。

デモアプリ

デモアプリの中身は
「+ボタンを押すとカウントが1ずつ増えていく」
という簡単なアプリになります

ここから色々とカスタマイズしていくと面白いかもしれませんね😀

まとめ

デモアプリの起動を確認できました!
次回はコード内のコメントなどを見ていきながら
少しずつコードを書いていきたいと思います

Flutterについて

概要

この記事では最近個人的興味のあるFlutterについて
アウトプットしていきます

Flutterって何者?

『Flutter』とは、Googleが開発した、モバイルアプリケーションのSDKです。
SDKとはsoftware development kitの略
Flutterでは、1つのコードでAndroidとiOSのどちらでもアプリを作成できます
またモバイルだけでなく、最近ではウェブ・デスクトップアプリ化も可能になりました。

このクロスプラットフォームに対応したフレームワークにとても興味が湧きました。

ちなみに
クロスプラットフォームに対応したフレームワークはFlutterだけではありません
React NativeやXamarinなどがあります。

特徴

次はFlutterの特徴についてです
初学者目線でFlutterの凄さについて記述していきます

ホットリロード

Flutterではホットリロードという機能があります
ホットリロードとは
開発中にコードを変更した際にその変更がすぐに確認可能になる機能です
Androidではエミュレーター
iOSではシミュレーター
を用いてコードの変更を高速に確認することが出来ます

Dart言語での開発

Flutterは、「Dart」という言語を使って開発をしていきます
聞き慣れない言語だったので調べてみると
もともと「Dart」は、JavaScriptの代替言語として2011年にリリースされたそうです
なのでJavaScriptや、JAVAを扱っている方にとってはそれほど構える必要は無いようです

私はJSもJAVAも全くの初学者なので勉強は必要です笑

UI開発が高速

Google推奨の『マテリアルデザイン』のツールキット
iOSのデザインスタンダード『クパティーノ』のライブラリ
この二つのUIが用意されているのでAndroidとiOSのどちらでもアプリも高速に開発ができるようです

まとめ

flutterを知ったとき何この万能さん!
と思ったことがflutterを学習したいと思ったきっかけでした
fultterはまだまだ新しいものなので参考資料など
数が圧倒的に少なく学習は困難を要すると思いますが
頑張って習得していきたいと思います!

Git GitHubに触れてみよう(準備編)

概要

プログラミングスクールにてGitの使い方を学びましたが
主にGUIツールである「GitHubDesktop」での学習だったので
ターミナル上でGitを扱うことを想定してアウトプットしていきます
※主にMacOSでの操作になります

Gitのインストール

MacにはGitが標準搭載されているみたいですが一応確認していきます
ターミナル上でGitがインストールされているか確認してみましょう。

git version
↓実行後
git version 2.24.3 (Apple Git-128)

上記のようにバージョンが表示されていればGitはインストールされています

もし出ない方がいればコマンド実行後ポップアップが表示されます

f:id:paddy_north:20201106141433p:plain
ポップアップで表示

「インストール」をクリックして、「コマンドライン・デベロッパー・ツール」をインストールしましょう

また
・インストーラーでGitをインストールする方法
・Homebrewを使ってGitをインストールする方法
・Gitをアップデートする方法
がありますのでこちらの記事を参考にしてみて下さい
Git のインストール 〜Git をMacにインストールしよう〜 | バージョン管理システム入門(初心者向け)

GitHubの登録

GidHubのサイト
上記のリンクよりGitHubの登録を行えます

登録に関しては下記の記事を参考にして下さい
GitHub 入門 ~アカウントを作成する方法~ | サービス | プロエンジニア

Gitの初期設定

初期設定を行っていきましょう

git config --global user.name "First-name Family-name"
git config --global user.email "username@example.com"

ユーザー名とアドレスの登録をおこなっています
””の中にGitHubで登録した情報を入力して下さい

他にも色々と設定できますがここでは2つのみです
どんな設定ができるかなどは下記の記事を参考にして下さい
Mac Git 初期設定 - Qiita

Gitの設定を確認したい場合は下記のコマンドを実行してみましょう

git config --list

なお今回設定したことは
ホームディレクトリの下の.gitconfigファイルに設定されています
確認したい場合は

cat ~/.giconfig

で確認できます
またcatというコマンドはファイルの内容を表示する
というコマンドなので覚えておくと役に立つかもしれません