新建一个页面的基础代码

空安全普通页面

import 'package:flutter/material.dart';
class PageName extends StatefulWidget {
  final Map? arguments;
  const PageName({Key? key, this.arguments}) : super(key: key);
  @override
   createState() => _PageNameState();
}

class _PageNameState extends State<PageName> {


  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      right: true,
      bottom: false,
      left: true,
      top: false,
      child: Scaffold(
        appBar: AppBar(title: const Text("标题"),),
        body:Container(),
      ),
    );
  }
}

空安全根页面或想保留状态的页面

import 'package:flutter/material.dart';
class PageName extends StatefulWidget {
  final Map? arguments;
  const PageName({Key? key, this.arguments}) : super(key: key);
  @override
   createState() => _PageNameState();
}

class _PageNameState extends State<PageName> with AutomaticKeepAliveClientMixin{

  @override
  bool get wantKeepAlive => true;

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return SafeArea(
      right: true,
      bottom: false,
      left: true,
      top: false,
      child: Scaffold(
        appBar: AppBar(title: const Text("标题"),),
        body:Container(),
      ),
    );
  }
}

非空安全页面(尽量舍弃)

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class PageName extends StatefulWidget {
  final arguments;
  const PageName({Key key, this.arguments}) : super(key: key);

  @override
  _PageNameState createState() => _PageNameState();
}

class _PageNameState extends State<PageName> {
  

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      right: true,
      bottom: false,
      left: true,
      top: false,
      child: Scaffold(
        appBar: AppBar(title: Text('标题'),),
        body:Container(),
      ),
    );
  }
}