mirror of
https://github.com/flutter/flutter
synced 2024-10-14 04:02:56 +00:00
Assert that url is non-null in NetworkImage (#9626)
This commit is contained in:
parent
2e194d5b44
commit
9558ac7d55
|
@ -311,7 +311,7 @@ class NetworkImage extends ImageProvider<NetworkImage> {
|
|||
/// Creates an object that fetches the image at the given URL.
|
||||
///
|
||||
/// The arguments must not be null.
|
||||
const NetworkImage(this.url, { this.scale: 1.0 });
|
||||
const NetworkImage(this.url, { this.scale: 1.0 }) : assert(url != null);
|
||||
|
||||
/// The URL from which the image will be fetched.
|
||||
final String url;
|
||||
|
|
14
packages/flutter/test/services/image_provider_test.dart
Normal file
14
packages/flutter/test/services/image_provider_test.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2017 The Chromium Authors. 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/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('NetworkImage non-null url test', () {
|
||||
expect(() {
|
||||
new NetworkImage(null); // ignore: prefer_const_constructors
|
||||
}, throwsAssertionError);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue