prefer_is_empty and prefer_is_not_empty (#8474)

This commit is contained in:
Alexandre Ardhuin
2017-03-02 07:17:30 +01:00
committed by Adam Barth
parent 2f002885cc
commit 69b6bb87d1
12 changed files with 20 additions and 20 deletions

View File

@@ -29,7 +29,7 @@ class _CalculatorState extends State<Calculator> {
/// Pop the top expression off of the stack and make it the current expression.
void popCalcExpression() {
if (_expressionStack.length > 0) {
if (_expressionStack.isNotEmpty) {
_expression = _expressionStack.removeLast();
} else {
_expression = new CalcExpression.Empty();

View File

@@ -287,7 +287,7 @@ class CalcExpression {
// where a "term" is defined to be a sequence of numbers separated by
// multiplcation or division symbols.
num currentTermValue = removeNextTerm(list);
while (list.length > 0) {
while (list.isNotEmpty) {
OperationToken opToken = list.removeAt(0);
num nextTermValue = removeNextTerm(list);
switch (opToken.operation) {
@@ -312,10 +312,10 @@ class CalcExpression {
/// A "term" is a sequence of number tokens separated by multiplication
/// and division symbols.
static num removeNextTerm(List<ExpressionToken> list) {
assert(list != null && list.length >= 1);
assert(list != null && list.isNotEmpty);
final NumberToken firstNumToken = list.removeAt(0);
num currentValue = firstNumToken.number;
while (list.length > 0) {
while (list.isNotEmpty) {
bool isDivision = false;
OperationToken nextOpToken = list.first;
switch (nextOpToken.operation) {

View File

@@ -118,7 +118,7 @@ class OrderItem extends StatelessWidget {
class OrderPage extends StatefulWidget {
OrderPage({ Key key, this.order, this.products, this.shoppingCart }) : super(key: key) {
assert(order != null);
assert(products != null && products.length > 0);
assert(products != null && products.isNotEmpty);
assert(shoppingCart != null);
}

View File

@@ -54,7 +54,7 @@ class Product {
description != null &&
imageAsset != null &&
categories != null &&
categories.length > 0 &&
categories.isNotEmpty &&
price != null &&
vendor.isValid();
}

View File

@@ -309,7 +309,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
}
bool _firstLetterIsUpperCase(String str) {
if (str.length > 0) {
if (str.isNotEmpty) {
String first = str.substring(0, 1);
return first == first.toUpperCase();
}