当我运行“dart migrate”以启用空安全时,它会给出以下输出。
\n\nBefore migrating your package, we recommend ensuring that every library it\nimports (either directly or indirectly) has been migrated to null safety, so\nthat you will be able to run your unit tests in sound null checking mode. You\nare currently importing the following non-null-safe libraries:\n\n package:stepfly/common/Functions/Constants/constants.dart\n package:stepfly/common/Functions/Utils/random_string.dart\n package:stepfly/common/Functions/Utils/timeUtils.dart\n package:stepfly/common/Functions/Utils/utilExam.dart\n package:stepfly/common/Functions/Utils/utilInternet.dart\n package:stepfly/common/Functions/Utils/utils.dart\n package:stepfly/common/Functions/Utils/utilsResourse.dart\n package:stepfly/common/Functions/Utils/utilsUserData.dart\n package:stepfly/common/Responsive/enums/device_screen_type.dart\n package:stepfly/common/Responsive/platformInfo.dart\n package:stepfly/common/Responsive/responsive/responsive_builder.dart\n ......\n\nPlease upgrade the packages containing these libraries to null safe versions\nbefore continuing. To see what null safe package versions are available, run\nthe following …Run Code Online (Sandbox Code Playgroud) 我制作了一个容器,该容器应该显示周围有彩色边框的图片,并添加 borderRadius 将其设置为 8,但是后来我注意到,当我设置容器来剪辑内容时,它会使边框角褪色,如下所示:
我是这样写的
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Container(
height: 300,
width: 300,
decoration: BoxDecoration(
border: Border.all(color: Colors.red, width: 2),
borderRadius: const BorderRadius.all(Radius.circular(16)),
),
clipBehavior: Clip.antiAlias,
child: Container(
constraints: BoxConstraints.expand(),
color: Colors.blue,
),
),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
我希望内容不与我的边框重叠,该怎么做?
https://flutter.dev/docs/testing/build-modes
上面的页面有以下解释。
在调试模式下,启用服务扩展。
在发布模式下,服务扩展被禁用。Flutter 中的“服务扩展”是什么?
单击按钮时,我试图获取要导航到的屏幕名称(在自定义类中)。
class myButton extends StatelessWidget {
String button_txt = '';
String nextPage = '';
double height_ = 39;
myButton(button_txt) {
this.button_txt = button_txt;
this.nextPage = nextPage;
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.pushReplacement(context, '/$nextPage');
},
Run Code Online (Sandbox Code Playgroud) 我想在加载过程中使用我的应用程序图标。如何实施。目前我正在使用循环进度指示器。
return Center(
child: CircularProgressIndicator(
strokeWidth: 2));
Run Code Online (Sandbox Code Playgroud) 我有一个列和其中的三个元素。我将 mainAxisAlignment 设置为 MainAxisAlignment.spaceBetween,以便第一个元素位于我的应用程序顶部。第二个在中间,第三个在底部。现在我想将其包装在滚动视图中,以便如果列的内容比视图高,则可以滚动它。例如,当键盘弹出时就会发生这种情况。
我的代码看起来有点像这样:
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Element1(),
Element2(),
Element3(),
]
)
Run Code Online (Sandbox Code Playgroud)
Column 将其高度扩展到整个屏幕。这也是我想要的。
但现在如果我将它包装在 SingelChildScrollView 中,它会缩小到最小内容高度。:(
SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Element1(),
Element2(),
Element3(),
]
),
)
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以使列继续扩展到屏幕的整个视图高度,并且一旦其内容高于屏幕高度就可以滚动?
我正在使用Django rest-framework开发一个Flutter应用程序。注册api在Postman中运行良好,但是从flutter应用程序成功注册后,它会显示上述错误。该请求已通过https地址发送。
删除了csrf。没发生什么事。
var data = {'email':signupemailidcontroller.text,
'password1':passwordcontroller.text,
'password2':confirmpasswordcontroller.text,
};
//http request here
await http.post(websitesignupurl,
headers: headers,
body: json.encode(data))
.then((onResponse){
print(onResponse.body);
}).catchError((onerror){
print(onerror.toString());
});
Run Code Online (Sandbox Code Playgroud)
SocketException:操作系统错误:连接被拒绝,errno = 111
我希望这个请求的响应是一个包含用户和令牌的Json对象。
我试图在一个类中使用periodic该类的方法Timer,该类扩展了该类ChangeNotifier(包Provider),使我的变量time每秒都在减少。
如果我不添加NotifyListeners重绘占用该time属性的所有小部件的方法,则此方法可以正常工作,例如:
class PriceProvider extends ChangeNotifier{
int _time = 60;
int get time{
return _time;
}
void chronometer(){//method which activate the timer
Timer _timer = Timer.periodic(const Duration(seconds: 1), (Timer timer){
print(DateTime.now());//I print the date so you can see how often the code is executed
_time += -1;//decrease time
if(_time == 0){
_time = 60;
}
// notifyListeners();
});
}
}
Run Code Online (Sandbox Code Playgroud)
另一方面,如果我取消对该NotifyListeners方法的注释,代码开始以指数方式每秒执行越来越多的次数(例如,首先执行一次,然后两次,然后 5 次,然后 …