我正在尝试创建一些使用DartPad Flutter在扑朔迷离中使用容器的示例。一切正常,直到我使用BorderRadius属性,在其中出现以下错误:
错误:断言失败:file:///Users/brettmorgan/Documents/GitHub/dart-services/flutter/packages/flutter/lib/src/foundation/stack_frame.dart:115:12 匹配!= null “预期的DartError @ https://storage.googleapis.com/compilation_artifacts/2.9.0-21.10.beta/dart_sdk.js:5956:7匹配RegExp /^(.+)(\ d +):(\ d +)\ s +(。+)$ /。”错误:错误:断言失败:file:///Users/brettmorgan/Documents/GitHub/dart-services/flutter/packages/flutter/lib/src/foundation/stack_frame.dart:115 :12 匹配!= null “预期的DartError @ https://storage.googleapis.com/compilation_artifacts/2.9.0-21.10.beta/dart_sdk.js:5956:7匹配RegExp /^(.+)(\ d +):(\ d +)\ s +(。+)$ /。”
源代码为:
import 'package:flutter/material.dart';
final Color blue = Colors.blue;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: blue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
decoration: const BoxDecoration(
border: Border(
top: BorderSide(width: 5.0, color: Color(0xFFFFDFDFFF)),
left: BorderSide(width: 5.0, color: Color(0xFFFFDFDFFF)),
right: BorderSide(width: 5.0, color: Color(0xFFFF7F7F88)),
bottom: BorderSide(width: 5.0, color: Color(0xFFFF7F7F88)),
),
borderRadius: BorderRadius.all( Radius.circular(10)),
color: Color(0xFFBFBFCC),
),
margin: const EdgeInsets.all(20.0),
padding: const EdgeInsets.all(10.0),
child: Text('The Battle of containers',style : TextStyle(color:Colors.black)),
width: 200.0,
height: 100.0,
),
);
}
}
那么,DartPad不支持BorderRadius吗?
答案 0 :(得分:0)
我发现问题出在“ const ”关键字中: 装饰: const BoxDecoration(行。 当我删除它时,它可以正常工作。