Commit 9558ac7d authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Assert that url is non-null in NetworkImage (#9626)

parent 2e194d5b
......@@ -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;
......
// 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);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment