How to send data from one screen to other in flutter app with route navigator

Zain Ahmed
2 min readMay 25, 2020

--

in this artical we will learn how we can send data like key value from one screen to other screen. for that there are some steps and code let see.

step 1: on screen one from where you want to send data , create class with any suitable name , and in this class declare variables which you want to send like this.

now after this i create button on this button press function will call name _sendData with 2 params id and name

function _sendData with params

in this pic i create a function and on call it i create a final variable which assign the values of id and name to class Data and after assign data will send with navigator.push method to that other screen where you want to send it .

second screen on which i receive data

so now after all done on screen one we now move to screen two , on which i create a variable and a class constructor showing in first green box

now on last where we want to print\display the variable value we use in string like ‘${variable name}’ and most important by using this login we can find or variables in “widget” just like in pic.

hope this help you guys . if you want to watch the video also on it link is here

--

--

Zain Ahmed
Zain Ahmed

Written by Zain Ahmed

Hello everyone, I am Zain Anmed a software engineer by profession, passionate about trying different technologies and trying some other cool stuff.

No responses yet