美文网首页
2019-10-29

2019-10-29

作者: Nazarite_0141 | 来源:发表于2019-10-29 22:52 被阅读0次
    import 'package:flutter/material.dart';
    
    void main(){
      runApp(MaterialApp(
        title: "导航演示01",
        home: new FirstScreen(),
      ));
    }
    
    class FirstScreen extends StatelessWidget{
      @override
      Widget build(BuildContext context) {
        // TODO: implement build
        return Scaffold(
          appBar: AppBar(title: Text('导航页面'),),
          body: Center(
            child: RaisedButton(
              child: Text('查看商品详情页'),
              onPressed: (){
                Navigator.push(context, MaterialPageRoute(
                  builder: (context)=> SecondScreen()
                ));
              },
            ),
          ),
        );
      }
    }
    
    class SecondScreen extends StatelessWidget{
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text('商品详情页面'),),
         body: Center(
           child: RaisedButton(
             child: Text('返回'),
             onPressed: (){
               Navigator.pop(context);
             },
           ),
         ),
        );
      }
    }
    
    

    相关文章

      网友评论

          本文标题:2019-10-29

          本文链接:https://www.haomeiwen.com/subject/ctjnvctx.html