Skip to content

Commit b88de33

Browse files
committed
codespace is all set
1 parent 8ceffc5 commit b88de33

18 files changed

+693
-0
lines changed

.devcontainer/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM dart
2+
3+
RUN apt-get update
4+
RUN apt-get install -y curl git unzip xz-utils zip libglu1-mesa
5+
6+
RUN apt-get clean
7+
8+
RUN git clone https://github.com/flutter/flutter.git -b stable --depth 1 /flutter
9+
ENV PATH="/flutter/bin:$PATH"
10+
RUN flutter doctor

.devcontainer/devcontainer.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile"
4+
},
5+
"forwardPorts": [3000],
6+
"name": "Flutter",
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"Dart-Code.dart-code",
11+
"Dart-Code.flutter"
12+
]
13+
}
14+
}
15+
}

.gitignore

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Symbolication related
36+
app.*.symbols
37+
38+
# Obfuscation related
39+
app.*.map.json
40+
41+
# Android Studio will place build artifacts here
42+
/android/app/debug
43+
/android/app/profile
44+
/android/app/release

.metadata

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled.
5+
6+
version:
7+
revision: 4b12645012342076800eb701bcdfe18f87da21cf
8+
channel: stable
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 4b12645012342076800eb701bcdfe18f87da21cf
17+
base_revision: 4b12645012342076800eb701bcdfe18f87da21cf
18+
- platform: web
19+
create_revision: 4b12645012342076800eb701bcdfe18f87da21cf
20+
base_revision: 4b12645012342076800eb701bcdfe18f87da21cf
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Flutter on Codespaces ❤
2+
3+
This is a repository for developing with [Flutter](https://flutter.dev/) on the web on [GitHub Codespaces](https://github.com/features/codespaces).
4+
5+
Flutter is a cross-platform UI framework by Google for building apps. Codespaces is a cloud-based development environment that lets you run a full-featured IDE in the cloud. This repository lets you get started with Flutter on Codespaces in just a few clicks.
6+
7+
**Table of Contents**
8+
- [Setup](#setup)
9+
- [Getting started](#getting-started)
10+
- [Flutter Development](#flutter-development)
11+
- [Developing for mobile](#developing-for-mobile)
12+
- [Codespaces Usage](#codespaces-usage)
13+
- [Managing your codespace](#managing-your-codespace)
14+
15+
## Setup
16+
17+
### Getting started
18+
19+
1. Fork this repository.
20+
21+
2. In your new repository, press "Code", select "Codespaces", then press "Create codespace on main". A container with everything you need to get started will be created automatically, then you'll be taken to your new codespace (VS Code in your browser). If you'd prefer to work on your codespace using the VS Code desktop app instead of the browser app, you can follow these instructions.
22+
23+
3. Press the "Extensions" icon in the left sidebar. You'll see that the Flutter and Dart extensions are already being installed. The environment won't work properly until the installation is complete, so wait for it to finish.
24+
25+
4. In your integrated terminal (the TERMINAL tab), run `flutter pub get` to install the missing Flutter dependencies.
26+
27+
5. In the ports view (the PORTS tab), port 3000 should be listed there already. Right click on it, and, under "Port Visibility", select "Public". This is important so the app can access services on your client from other server ports without getting blocked due to CORS.
28+
29+
6. Run `./run.sh` in the terminal to start the app. A notification will appear saying that an app opened on port 3000. You can press "Open in Browser" to open it, but it won't load until the terminal shows that it's ready. You can refresh once the app is loaded (as indicated by a prompt to press "R" to reload).
30+
31+
> You can find the link to access the app in your browser at any time by going to the ports view, right clicking on port 3000, and pressing "Open in Browser".
32+
33+
7. That's it! Make changes in `lib/main.dart`, press "R" in the terminal, then refresh the page to see your changes appear quickly.
34+
35+
## Flutter Development
36+
37+
### Developing for mobile
38+
39+
Running Flutter in Codespaces makes it a bit difficult to run the app in a mobile simulator. However, developing for the web is basically the same as developing for mobile. I'd recommend opening your browser's developer tools and selecting a mobile device to emulate.
40+
41+
If you're using Chrome or another Chromium-based browser, you can open DevTools like [this](https://developer.chrome.com/docs/devtools/open/) and emulate a device like [this](https://developer.chrome.com/docs/devtools/device-mode/). It'll be pretty similar for other browsers like Safari and Firefox.
42+
43+
## Codespaces Usage
44+
45+
### Managing your codespace
46+
47+
When you're not using your codespace, deactivate it by going to [Codespaces](https://github.com/codespaces), pressing the 3 dots on the right side of the codespace, and pressing "Stop codespace". You can also deactivate it within the codespace by pressing "Codespaces" at the bottom left of VS Code and selecting "Stop Current Codespace".

analysis_options.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

lib/main.dart

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import 'package:flutter/material.dart';
2+
3+
void main() {
4+
runApp(const MyApp());
5+
}
6+
7+
class MyApp extends StatelessWidget {
8+
const MyApp({super.key});
9+
10+
// This widget is the root of your application.
11+
@override
12+
Widget build(BuildContext context) {
13+
return MaterialApp(
14+
title: 'Flutter Demo',
15+
theme: ThemeData(
16+
// This is the theme of your application.
17+
//
18+
// Try running your application with "flutter run". You'll see the
19+
// application has a blue toolbar. Then, without quitting the app, try
20+
// changing the primarySwatch below to Colors.green and then invoke
21+
// "hot reload" (press "r" in the console where you ran "flutter run",
22+
// or simply save your changes to "hot reload" in a Flutter IDE).
23+
// Notice that the counter didn't reset back to zero; the application
24+
// is not restarted.
25+
primarySwatch: Colors.blue,
26+
),
27+
home: const MyHomePage(title: 'Flutter Demo Home Page'),
28+
);
29+
}
30+
}
31+
32+
class MyHomePage extends StatefulWidget {
33+
const MyHomePage({super.key, required this.title});
34+
35+
// This widget is the home page of your application. It is stateful, meaning
36+
// that it has a State object (defined below) that contains fields that affect
37+
// how it looks.
38+
39+
// This class is the configuration for the state. It holds the values (in this
40+
// case the title) provided by the parent (in this case the App widget) and
41+
// used by the build method of the State. Fields in a Widget subclass are
42+
// always marked "final".
43+
44+
final String title;
45+
46+
@override
47+
State<MyHomePage> createState() => _MyHomePageState();
48+
}
49+
50+
class _MyHomePageState extends State<MyHomePage> {
51+
int _counter = 0;
52+
53+
void _incrementCounter() {
54+
setState(() {
55+
// This call to setState tells the Flutter framework that something has
56+
// changed in this State, which causes it to rerun the build method below
57+
// so that the display can reflect the updated values. If we changed
58+
// _counter without calling setState(), then the build method would not be
59+
// called again, and so nothing would appear to happen.
60+
_counter++;
61+
});
62+
}
63+
64+
@override
65+
Widget build(BuildContext context) {
66+
// This method is rerun every time setState is called, for instance as done
67+
// by the _incrementCounter method above.
68+
//
69+
// The Flutter framework has been optimized to make rerunning build methods
70+
// fast, so that you can just rebuild anything that needs updating rather
71+
// than having to individually change instances of widgets.
72+
return Scaffold(
73+
appBar: AppBar(
74+
// Here we take the value from the MyHomePage object that was created by
75+
// the App.build method, and use it to set our appbar title.
76+
title: Text(widget.title),
77+
),
78+
body: Center(
79+
// Center is a layout widget. It takes a single child and positions it
80+
// in the middle of the parent.
81+
child: Column(
82+
// Column is also a layout widget. It takes a list of children and
83+
// arranges them vertically. By default, it sizes itself to fit its
84+
// children horizontally, and tries to be as tall as its parent.
85+
//
86+
// Invoke "debug painting" (press "p" in the console, choose the
87+
// "Toggle Debug Paint" action from the Flutter Inspector in Android
88+
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
89+
// to see the wireframe for each widget.
90+
//
91+
// Column has various properties to control how it sizes itself and
92+
// how it positions its children. Here we use mainAxisAlignment to
93+
// center the children vertically; the main axis here is the vertical
94+
// axis because Columns are vertical (the cross axis would be
95+
// horizontal).
96+
mainAxisAlignment: MainAxisAlignment.center,
97+
children: <Widget>[
98+
const Text(
99+
'You have pushed the button this many times:',
100+
),
101+
Text(
102+
'$_counter',
103+
style: Theme.of(context).textTheme.headlineMedium,
104+
),
105+
],
106+
),
107+
),
108+
floatingActionButton: FloatingActionButton(
109+
onPressed: _incrementCounter,
110+
tooltip: 'Increment',
111+
child: const Icon(Icons.add),
112+
), // This trailing comma makes auto-formatting nicer for build methods.
113+
);
114+
}
115+
}

0 commit comments

Comments
 (0)