mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 23:08:59 +00:00
Add a new null safety example (#562)
This commit is contained in:
36
experimental/null_safety/null_safe_app/lib/badapp.dart
Normal file
36
experimental/null_safety/null_safe_app/lib/badapp.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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.
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user