zoukankan      html  css  js  c++  java
  • flutter 页面跳转1

    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Material Components',
          home: FirstPage(),
        );
      }
    }
    
    class FirstPage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('第一页'),
          ),
    
          body: Padding(
    //        padding: EdgeInsets.all(60.0),
    //        padding: EdgeInsets.fromLTRB(0, 200, 30, 0),
            padding: EdgeInsets.only(top: 10,right: 30),// 指定任意方向的值
            child: RaisedButton(
    
              child:  Text('跳转到第二页'),
              onPressed: () {
                Navigator.push(//1
                  context,
                  MaterialPageRoute(builder: (context) => SecondPage()),
                );
              },
              color: Color(0xfff1f433),
            ),
    
          ),
    
        );
      }
    }
    
    class SecondPage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('第二页'),
          ),
          body: Padding(
            padding: EdgeInsets.all(30.0),
            child: RaisedButton(
                child: Text('回到上一页'),
                onPressed: () {
                  Navigator.pop(context);//2
                }),
          ),
        );
      }
    }

    跑起来先

  • 相关阅读:
    软件工程课程总结
    c#代码分析
    运用visual studio进行简单的单元测试
    安装visual studio过程
    忙着,快乐着
    软件工程心得
    session
    XML
    期末团队评价
    黄金点游戏
  • 原文地址:https://www.cnblogs.com/gaozhang12345/p/11982014.html
Copyright © 2011-2022 走看看