去掉DeBug图标
在我们进行编写代码预览时,有一Debug的图标一直在屏幕上,确实不太美观,其实只要语句代码就可以去掉的
- debugShowCheckedModeBanner: false,
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
//去掉DeBug图标
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold());
}
}
打电话
import 'package:url_launcher/url_launcher.dart';
void _launchPhone(String? phone) async {
var url = "tel:${phone ?? ''}";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
屏幕宽度和高度
MediaQuery.of(context).size.width
MediaQuery.of(context).size.height
///初始化 ScreenUtil 屏幕适配
void initScreen(context) {
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(375, 812),
orientation: Orientation.portrait);
}