-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deve ter sido apagado por uma das entregas
- Loading branch information
1 parent
c07c82d
commit 9c09710
Showing
25 changed files
with
1,132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release | ||
|
||
/android/ | ||
/ios/ | ||
/linux/ | ||
/windows/ | ||
/macos/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
channel: stable | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
- platform: android | ||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
- platform: ios | ||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
- platform: linux | ||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
- platform: macos | ||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
- platform: web | ||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
- platform: windows | ||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## Exemplos auxiliares | ||
Este mini-projeto mostra algumas funcionalidades possíveis com o flutter. | ||
Não é exaustivo, mas consegue dar uma ideia das coisas que se possam fazer a framework. | ||
|
||
### Exemplos | ||
Os exemplos aqui mostrados são os seguintes: | ||
- **Default**: O exemplo default do flutter, um que seja gerado automaticamente pelo comando `flutter create <nome_do_projeto>` por exemplo. | ||
Está guardado num único ficheiro e foi deixado para o caso de se querer verificar como é que é o resultado proveniente do default. | ||
Este exemplo apresenta um `Floating Action Button`, `Stateful` e `Stateless` widgets, `Center` e `Column` para organização. | ||
Está bem organizado e documentado, por isso, deixo para dar mais valor aos restantes exemplos (que são mais simples por comparação); | ||
- **Menu**: Um exemplo simples de como fazer um *menu*. | ||
Este menu apenas contem `Elevated Button`s para poder guiar o utilizador da página principal para uma secundária, onde mostra a cor que o utilizador escolheu. | ||
Claro que o design poderia estar melhor, mas o propósito aqui era de mostrar como criar um menu e como se pode guiar o utilizador de uma página para outra. | ||
Para além disso, há uma explicação no topo do ficheiro principal (aquele que tem o mesmo nome que a pasta) para poder ir mais ao detalhe como está montado. | ||
- **Infinite List**: Como o nome indica, é um exemplo de como se pode implementar uma *lista infinita* no flutter. | ||
No ficheiro principal tem-se a explicação de como isto é possível, sendo que os elementos mais importantes é teres uma `ListView.builder` e um widget que sirva para preencher a lista - para este tipo de casos, é normalmente usado `ListTile`. | ||
Em termos de conteúdo, poderia ter conteúdo mais importante, mas neste caso deixou-se que cada elemento da lista tivesse um formato `ListTile #<numero do item>` para simplificar a demonstração. | ||
- **Gallery**: Numa forma mais interessante e iterativa que os exemplos anteriores, este demo mostra como criar uma galeria de imagens proveniente de uma API e permite ao utilizador escolher uma das imagens para ser a que estiver no meio da página. | ||
Esta combina um pouco da **Infinite List** com a implementação do widget `Image.network`, a fim de mostrar as imagens, bem como usar o `InkWell` para adicionar a propriedade de *click* na imagem, quando se quer adicioná-la. | ||
Este exemplo é bastante simples no papel, mas pode ser desafiante a quem ainda não perceber os exemplos anteriores; | ||
- **Workshop 2**: A app que se usou como exemplo para o workshop. | ||
- **Workshop 3**: A app que se usou como exemplo prático para o workshop. | ||
|
||
Por enquanto são estes o exemplos adicionados, sendo que será avisado quando forem adicionados mais exemplos. | ||
|
||
> Nota! Estes exemplos não seguem a 100% as boas práticas, sendo que deves ver isto como `como implementar certa funcionalidade` e não como se escreve bom código. | ||
> Entre outras palavras, está por tua conta e risco se fizeres copy-paste e não funcionar | ||
Para poderes escolher o exemplo, tens de ir ao `lib/main.dart` e alterar o `exemploId` para uma das opções que terás em baixo. | ||
Caso queiras o `default`, basta colocares um nome qualquer, desde que não seja igual aos que estão alistados. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file configures the analyzer, which statically analyzes Dart code to | ||
# check for errors, warnings, and lints. | ||
# | ||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# invoked from the command line by running `flutter analyze`. | ||
|
||
# The following line activates a set of recommended lints for Flutter apps, | ||
# packages, and plugins designed to encourage good coding practices. | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
# The lint rules applied to this project can be customized in the | ||
# section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# included above or to enable additional rules. A list of all available lints | ||
# and their documentation is published at | ||
# https://dart-lang.github.io/linter/lints/index.html. | ||
# | ||
# Instead of disabling a lint rule for the entire project in the | ||
# section below, it can also be suppressed for a single line of code | ||
# or a specific dart file by using the `// ignore: name_of_lint` and | ||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# producing the lint. | ||
rules: | ||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class Default extends StatelessWidget { | ||
const Default({super.key}); | ||
|
||
// 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, | ||
), | ||
home: const MyHomePage(title: 'Flutter Demo Home Page'), | ||
); | ||
} | ||
} | ||
|
||
class MyHomePage extends StatefulWidget { | ||
const MyHomePage({super.key, required this.title}); | ||
|
||
// 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 | ||
State<MyHomePage> 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>[ | ||
const Text( | ||
'You have pushed the button this many times:', | ||
), | ||
Text( | ||
'$_counter', | ||
style: Theme.of(context).textTheme.headlineMedium, | ||
), | ||
], | ||
), | ||
), | ||
floatingActionButton: FloatingActionButton( | ||
onPressed: _incrementCounter, | ||
tooltip: 'Increment', | ||
child: const Icon(Icons.add), | ||
), // This trailing comma makes auto-formatting nicer for build methods. | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:auxiliar_examples/gallery/gallery_exposition.dart'; | ||
|
||
class Gallery extends StatelessWidget { | ||
const Gallery({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Galeria moderna', | ||
home: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Galeria moderna'), | ||
), | ||
body: const GalleryExposition(), | ||
), | ||
); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
appdev/auxiliar_examples/lib/gallery/gallery_exposition.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// Um exemplo de stateful widget, onde na parte central vais ter uma | ||
/// imagem vinda de url, `Image.network`, e em baixo tens uma galeria | ||
/// de imagens, montada do mesmo estilo que a lista infinita, às quais | ||
/// podes clicar e alterar a que estiver na principal. A particularidade | ||
/// deste widget, sobre o stateless, é que é possível alterar o que | ||
/// te pode aparecer à frente sem teres de montar uma página ou widget | ||
/// diferente. Alteras o link da `Image.network` e pedes para | ||
/// renderizar de novo com a função `setState`. O `Expanded` serve | ||
/// só para poder organizar melhor o layout, fazendo o controlo do | ||
/// mesmo pelo fit. | ||
class GalleryExposition extends StatefulWidget { | ||
const GalleryExposition({super.key}); | ||
|
||
@override | ||
State<GalleryExposition> createState() => _GalleryExpositionState(); | ||
} | ||
|
||
class _GalleryExpositionState extends State<GalleryExposition> { | ||
String currentURL = "https://picsum.photos/250?image=0"; | ||
String templateURL = "https://picsum.photos/250?image="; | ||
@override | ||
Widget build(BuildContext context) { | ||
return Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, | ||
children: [ | ||
Expanded( | ||
flex: 7, | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 12.0), | ||
child: Image.network(currentURL, fit: BoxFit.fill), | ||
), | ||
), | ||
Expanded( | ||
flex: 1, | ||
child: ListView.builder( | ||
itemCount: 50, | ||
scrollDirection: Axis.horizontal, | ||
itemBuilder: (BuildContext ctx, int index) { | ||
return InkWell( | ||
onTap: () { | ||
setState(() => currentURL = "$templateURL$index"); | ||
}, | ||
child: Image.network( | ||
"$templateURL$index", | ||
fit: BoxFit.fitHeight, | ||
), | ||
); | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
appdev/auxiliar_examples/lib/infinite_list/infinite_list.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// A `ListView.builder` funciona como um construtor em que lhes dá o material que | ||
/// ele deve construir quando necessário. Podes fazer um jogo com o index, como | ||
/// aqui tens, em que entre cada `ListTile` tens uma divisória, `Divider`. A lista | ||
/// torna-se infindável caso não lhe des a propriedade `itemCount`, sendo que aí | ||
/// só construirá o número de items que especificares aí. | ||
/// | ||
/// Recomendo veres a documentação em cada widget para perceberes o que cada peça | ||
/// faz neste caso, especialmente teres mais habilidade na `ListView` e na | ||
/// `ListTile`. | ||
class InfiniteList extends StatelessWidget { | ||
const InfiniteList({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Lista Infinita', | ||
home: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Lista Infinita'), | ||
), | ||
body: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 24.0), | ||
child: ListView.builder(itemBuilder: (BuildContext ctx, int index) { | ||
return index % 2 == 0 | ||
? ListTile( | ||
title: Center( | ||
child: Text("ListTile #${index / 2}"), | ||
), | ||
) | ||
: const Divider(thickness: 2); | ||
}), | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.