Use Flutter on Ubuntu

How to install Flutter on Ubuntu 20.10 and use it as a web server.

Installation of prerequisite software

sudo apt install clang curl pkg-config ninja-build cmake libblkid-dev libgtk-3-dev

Install Flutter

git clone https://github.com/flutter/flutter.git

Go to/usr/local/flutter

Set path

export PATH=$PATH:/usr/local/flutter/bin

Confirmation of installation

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.26.0-2.0.pre.220, on Linux, locale ja_JP.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 27.0.1)
    ✗ Flutter requires Android SDK 29 and the Android BuildTools 28.0.3
      To update the Android SDK visit
      https://flutter.dev/docs/get-started/install/linux#android-setup for
      detailed instructions.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for
      more details.
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] Connected device (2 available)

! Doctor found issues in 2 categories.

Software creation

flutter create myapp
cd myapp

Run as a web server (ports will be random)

$ flutter run -d web-server
Launching lib/main.dart on Web Server in debug mode...
Waiting for connection from debug service on Web Server...         25.3s
lib/main.dart is being served at http://localhost:42819

In the browser http://localhost:42819 To access flutter_jan07.png

To start by specifying a port

flutter run -d web-server --web-port=1234

Modify the program. Replace lib/main.dart with:

lib/main.dart


import 'package:flutter/material.dart';

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

class ExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HelloWorld(),
    );
  }
}

class HelloWorld extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
String str_out = 'Hello.\n';
str_out += 'It's sunny today.\n';
str_out += 'Jan/08/2021\n';
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Example App'),
      ),
      body: Container(
        alignment: Alignment.center,
        child: Text(
          str_out,
          style: TextStyle(
            fontSize: 70,
            fontWeight: FontWeight.bold,
          )
        ),
      )
    );
  }
}

Start the server and access from the browser flutter_jan08.png

Recommended Posts

Use Flutter on Ubuntu
Use mkdir on ubuntu
Use cpplapack on ubuntu
Using Flutter on Ubuntu (Part 2)
How to use Bio-Formats on Ubuntu 20.04
Preparing to use electron-react-boilerplate on Ubuntu 20.4
tmux on Ubuntu
Use docker in proxy environment on ubuntu 20.04.1
Use cljstyle with Spacemacs on Ubuntu on WSL2
Screen recording on Ubuntu 20.04
Web Bluetooth on Ubuntu20.04
[Flutter] Ubuntu 20.04 environment construction
Try DisplayLink on Ubuntu 20.04
Reinstall Kubernetes on Ubuntu 19.10
Use perltidy on CentOS 8
Install pyqt5 on ubuntu
Install Ruby on Ubuntu 20.04
Use mod_auth_cas on CentOS 8
Setting JAVA_HOME on Ubuntu
Use bat on Centos.
Install Autoware on Ubuntu 18.04.5
Put JetBrains on Ubuntu
Apache2 on Ubuntu20.04 LTS
Use Corretto 11 on Heroku
ubuntu on wsl part 10
Install Homebrew on Ubuntu 20.04
Run tiscamera on Ubuntu 18.04
Build Zabbix on Ubuntu 20.04
Create SSL certificate on Ubuntu 18.04
Building WebGIS on Ubuntu20.04 LTS
Install OpenJDK7 (JAVA) on ubuntu 14.04
Put Ubuntu 20.04.1 on Raspberry Pi 4
Build VNC Server on Ubuntu 20.04
Install Cybozu Office 10 on Ubuntu 20.4
Extend swap area on Ubuntu 18.04
Ubuntu on Windows Community Preview
Japanese input on Ubuntu20.04 Desktop
Use serial communication on Android
Oracle Java 8 on Docker Ubuntu
Install zabbix agent (5.0) on Ubuntu 18.04
Install MAV Proxy on Ubuntu 18.04
Use Swift Package on Playground
Install Arudino IDE on Ubuntu 20
Record video on ubuntu18.04 LTS
Introduced knowledge (wiki) on Ubuntu
Installing OpenMX on Ubuntu 18.04.5 LTS
Install Java on WSL Ubuntu 18.04
Ruby installation on WSL2 + Ubuntu 20.04
Install Ubuntu Desktop 20.10 on RaspberryPi4
Run chromium-mir-kiosk on Ubuntu Core
Install Arduino IDE on Ubuntu 20.04
Ubuntu on Windows build speed
Use devise on multiple models
Run java applet on ubuntu
Install raspi-config on Ubuntu 20.04 (LTS)
Use native code on Android
Install WordPress 5.5 on Ubuntu 20.04 LTS
Run Eclipse CDT on Ubuntu
Set up ansible-playbook on Ubuntu 20.04
Install PlantUML on Intellij on Ubuntu
Install Ubuntu Server 20.04 on Btrfs