Mudanças entre as edições de "Flutter - ListView"
De Aulas
Linha 1: | Linha 1: | ||
+ | |||
Afluentes: [[Dispositivos Móveis]]; [[Usabilidade, desenvolvimento web, mobile e jogos]] | Afluentes: [[Dispositivos Móveis]]; [[Usabilidade, desenvolvimento web, mobile e jogos]] | ||
= ListView Estática = | = ListView Estática = | ||
− | <syntaxhighlight lang= | + | <syntaxhighlight lang="dart"> |
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||
Linha 10: | Linha 11: | ||
MaterialApp( | MaterialApp( | ||
title: 'Flutter ListView', | title: 'Flutter ListView', | ||
− | theme: ThemeData( | + | theme: ThemeData(primarySwatch: Colors.deepOrange), |
− | |||
− | |||
home: Scaffold( | home: Scaffold( | ||
− | appBar: AppBar( | + | appBar: AppBar(title: const Text("ListView Simples")), |
− | |||
− | |||
body: Center( | body: Center( | ||
child: ListView( | child: ListView( | ||
children: const [ | children: const [ | ||
− | ListTile( | + | ListTile(leading: Icon(Icons.map), title: Text('Mapa')), |
− | + | ListTile(leading: Icon(Icons.photo_album), title: Text('Álbum')), | |
− | + | ListTile(leading: Icon(Icons.phone), title: Text('Fone')), | |
− | |||
− | ListTile( | ||
− | |||
− | |||
− | |||
− | ListTile( | ||
− | |||
− | |||
− | |||
], | ], | ||
), | ), | ||
Linha 39: | Linha 27: | ||
); | ); | ||
} | } | ||
+ | |||
</syntaxhighlight> | </syntaxhighlight> | ||
= Lista de Array = | = Lista de Array = | ||
− | <syntaxhighlight lang=dart> | + | <syntaxhighlight lang="dart"> |
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||
Linha 62: | Linha 51: | ||
'Biguaçu', | 'Biguaçu', | ||
'Itajaí', | 'Itajaí', | ||
− | 'Blumenau' | + | 'Blumenau', |
]; | ]; | ||
Edição atual tal como às 11h40min de 19 de maio de 2025
Afluentes: Dispositivos Móveis; Usabilidade, desenvolvimento web, mobile e jogos
ListView Estática
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: 'Flutter ListView',
theme: ThemeData(primarySwatch: Colors.deepOrange),
home: Scaffold(
appBar: AppBar(title: const Text("ListView Simples")),
body: Center(
child: ListView(
children: const [
ListTile(leading: Icon(Icons.map), title: Text('Mapa')),
ListTile(leading: Icon(Icons.photo_album), title: Text('Álbum')),
ListTile(leading: Icon(Icons.phone), title: Text('Fone')),
],
),
),
),
),
);
}
Lista de Array
import 'package:flutter/material.dart';
void main() => runApp(const App());
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
var cities = [
'Florianópolis',
'São José',
'Palhoça',
'Biguaçu',
'Itajaí',
'Blumenau',
];
@override
build(context) {
return MaterialApp(
title: 'Lista',
home: Scaffold(
appBar: AppBar(title: const Text("Cidades")),
body: ListView.builder(
itemCount: cities.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
leading: const Icon(Icons.location_city),
title: Text(cities[index]),
);
},
),
),
);
}
}