去掉DeBug图标

在我们进行编写代码预览时,有一Debug的图标一直在屏幕上,确实不太美观,其实只要语句代码就可以去掉的

  • debugShowCheckedModeBanner: false,
  1. import 'package:flutter/material.dart';
  2. void main() => runApp(MyApp());
  3. class MyApp extends StatelessWidget {
  4. @override
  5. Widget build(BuildContext context) {
  6. return MaterialApp(
  7. title: 'Flutter Demo',
  8. //去掉DeBug图标
  9. debugShowCheckedModeBanner: false,
  10. theme: ThemeData(
  11. primarySwatch: Colors.blue,
  12. ),
  13. home: Scaffold());
  14. }
  15. }

打电话

  1. import 'package:url_launcher/url_launcher.dart';
  2. void _launchPhone(String? phone) async {
  3. var url = "tel:${phone ?? ''}";
  4. if (await canLaunch(url)) {
  5. await launch(url);
  6. } else {
  7. throw 'Could not launch $url';
  8. }
  9. }

屏幕宽度和高度

  1. MediaQuery.of(context).size.width
  2. MediaQuery.of(context).size.height
  1. ///初始化 ScreenUtil 屏幕适配
  2. void initScreen(context) {
  3. ScreenUtil.init(
  4. BoxConstraints(
  5. maxWidth: MediaQuery.of(context).size.width,
  6. maxHeight: MediaQuery.of(context).size.height),
  7. designSize: Size(375, 812),
  8. orientation: Orientation.portrait);
  9. }