prefer_is_empty and prefer_is_not_empty (#8474)
This commit is contained in:
committed by
Adam Barth
parent
2f002885cc
commit
69b6bb87d1
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class Product {
|
||||
description != null &&
|
||||
imageAsset != null &&
|
||||
categories != null &&
|
||||
categories.length > 0 &&
|
||||
categories.isNotEmpty &&
|
||||
price != null &&
|
||||
vendor.isValid();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user