Skip to content

Instantly share code, notes, and snippets.

@timsneath
Created October 22, 2020 16:45
Show Gist options
  • Save timsneath/4e6fa1f0131adee15dd236d8cab9c88d to your computer and use it in GitHub Desktop.
Save timsneath/4e6fa1f0131adee15dd236d8cab9c88d to your computer and use it in GitHub Desktop.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Get data from services. Note: in a real application,
// these would be async calls, but we're using sync calls
// for simplicity.
final localizedAppName = Config.getAppName();
final temperatures = WeatherService.getTemperatures();
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text(localizedAppName)),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Temperature next 3 days:'),
for (final t in temperatures)
Text(t.round().toString()),
],
),
),
),
);
}
}
class Config {
static String getAppName() { ... }
}
class WeatherService {
static List<double> getTemperatures() { ...}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment