Navigator.pop

Navigator.pop

Navigator.pop(context) → bool 

Navigator.of(context).pop()

açıklama

Önceki sayfaya geri dön.

konum

                  RaisedButton(
                                child: Text('İkinci Sayfa'),
                                onPressed: () {
                                                 Navigator.of(context).pop(); 
                                              },
                              ),

parametreler

Navigator.pop(context) → bool  // pop yap, true/ false ver : Navigator.of(context).pop(); 

örnek uygulama

MaterialPageRoute-navigator-pop-orn
	
    import 'package:flutter/material.dart';

    void main() {
      runApp(MaterialApp(
        title: 'Flutter',
        home: FirstScreen(),
      ));
    }

    class FirstScreen extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text('First screen')),
          body: Center(
            child: RaisedButton(
              child: Text(
                'Go to second screen',
                style: TextStyle(fontSize: 24),
              ),
              onPressed: () {
                _navigateToSecondScreen(context);
              },
            )
          ),
        );
      }

      void _navigateToSecondScreen(BuildContext context) {
        Navigator.push(
            context,
            MaterialPageRoute(
              builder: (context) => SecondScreen(),
            ));
      }
    }

    class SecondScreen extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text('Second screen')),
          body: Center(
            child: RaisedButton(
              child: Text(
                'Go back to first screen',
                style: TextStyle(fontSize: 24),
              ),
              onPressed: () {
                _goBackToFirstScreen(context);
              },
            ),
          ),
        );
      }

      void _goBackToFirstScreen(BuildContext context) {
        Navigator.pop(context);
      }
    }
	
		

Bir cevap yazın

KAPAT
%d blogcu bunu beğendi: