当我运行“ flutter run”并尝试查看结果时,出现了如下所示的错误。
它似乎与EdgeInsets有关。以下是我仍在处理的源代码。
import 'package:flutter/material.dart';
main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget{
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _MyAppState();
}
}
class _MyAppState extends State<MyApp> {
List<String> _products = ['Food Tester'];
build(context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('EasyList'),
),
body: Column(
children: [
Container(
margin: EdgeInsets.all(8.0,2),
child: RaisedButton(
onPressed: () {},
child: Text('Add product'),
),
),
Column(children: _products.map((element) =>Card(
child: Column(
children: <Widget>[Image.asset("assets/food.jpg"), Text(element)],
),
)).toList()),
],
),
));
}
}
以下是错误:
$ flutter run --debug
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 1.4s
Resolving dependencies... 1.3s
Running 'gradlew assembleDebug'...
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/card.dart:68:24: Error: Too few positional arguments: 2 required, 1 given.
compiler message: this.margin: const EdgeInsets.all(4.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/card.dart:113:33: Error: Too few positional arguments: 2 required, 1 given.
compiler message: margin: margin ?? const EdgeInsets.all(4.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/chip_theme.dart:233:46: Error: Too few positional arguments: 2 required, 1 given.
compiler message: const EdgeInsetsGeometry padding = const EdgeInsets.all(4.0);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/date_picker.dart:123:25: Error: Too few positional arguments: 2 required, 1 given.
compiler message: padding = const EdgeInsets.all(8.0);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/expand_icon.dart:28:25: Error: Too few positional arguments: 2 required, 1 given.
compiler message: this.padding: const EdgeInsets.all(8.0)
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/expansion_panel.dart:159:30: Error: Too few positional arguments: 2 required, 1 given.
compiler message: padding: const EdgeInsets.all(16.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/icon_button.dart:75:25: Error: Too few positional arguments: 2 required, 1 given.
compiler message: this.padding: const EdgeInsets.all(8.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/input_border.dart:319:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(borderSide.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/outline_button.dart:440:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/popup_menu.dart:818:25: Error: Too few positional arguments: 2 required, 1 given.
compiler message: this.padding: const EdgeInsets.all(8.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/progress_indicator.dart:542:21: Error: Too few positional arguments: 2 required, 1 given.
compiler message: margin: const EdgeInsets.all(4.0), // accommodate the shadow
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/progress_indicator.dart:548:26: Error: Too few positional arguments: 2 required, 1 given.
compiler message: padding: const EdgeInsets.all(12.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/stepper.dart:601:28: Error: Too few positional arguments: 2 required, 1 given.
compiler message: padding: const EdgeInsets.all(24.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/tabs.dart:1205:21: Error: Too few positional arguments: 2 required, 1 given.
compiler message: margin: const EdgeInsets.all(4.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/material/time_picker.dart:1528:22: Error: Too few positional arguments: 2 required, 1 given.
compiler message: padding: const EdgeInsets.all(16.0),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/beveled_rectangle_border.dart:46:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/circle_border.dart:35:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/rounded_rectangle_border.dart:45:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/rounded_rectangle_border.dart:160:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/stadium_border.dart:36:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/stadium_border.dart:143:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/stadium_border.dart:296:16: Error: Too few positional arguments: 2 required, 1 given.
compiler message: return new EdgeInsets.all(side.width);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/cupertino/button.dart:33:42: Error: Too few positional arguments: 2 required, 1 given.
compiler message: const EdgeInsets _kButtonPadding = const EdgeInsets.all(16.0);
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/cupertino/dialog.dart:276:22: Error: Too few positional arguments: 2 required, 1 given.
compiler message: padding: new EdgeInsets.all(8.0 * textScaleFactor),
compiler message: ^
compiler message: file:///Users/Ashley/development/flutter/packages/flutter/lib/src/painting/edge_insets.dart:336:9: Context: Found this candidate, but the arguments don't match.
compiler message: const EdgeInsets.all(double value, int i)
compiler message: ^^^
Compiler failed on /Users/Ashley/development/flutter_course_app/lib/main.dart
FAILURE: Build failed with an exception.
* Where:
Script '/Users/Ashley/development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 435
* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command '/Users/Ashley/development/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
Gradle build failed: 1
答案 0 :(得分:1)
EdgeInsets.all
仅接受一个参数(请参见EdgeInsets.all
api docs)。当您编写EdgeInsets.all(8.0,2)
时,出现了编译错误。
答案 1 :(得分:-1)
使用边距: EdgeInsets.all(8.0),