1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-05 03:01:19 +00:00

Upgrade null safety example (#748)

This commit is contained in:
Michael Thomsen
2021-03-03 22:01:08 +01:00
committed by GitHub
parent 8c1cd0b049
commit b0e8686fe9
144 changed files with 33 additions and 35 deletions

View File

@@ -0,0 +1,38 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// ignore_for_file: unused_local_variable
import 'package:flutter/material.dart';
import 'services.dart';
// This app doesn't work correctly when the services return null. Try to
// uncomment the for-loop and appBar lines below, and note how the new null
// safety static analysis immediately flags those lines as errors.
class BadMyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final localizedAppName = Config.getAppName();
final temperatures = WeatherService.getTemperatures();
var tempWidgets = [
Text('Temperature next 3 days:'),
// for (final t in temperatures) Text(t.round().toString()),
];
return MaterialApp(
home: Scaffold(
// appBar: AppBar(title: Text(localizedAppName)),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: tempWidgets,
),
),
),
);
}
}