Skip to content

apgapg/flutter_sample_key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter_sample_key

A sample on how to use keys in flutter. Full article here

PROBLEM STATEMENT:

Suppose we have two simple TextFields (wrapped as a stateful widget named MyTextField) in a Column and let’s say you hide the first of two on FAB(Floating Action Button) press. The first one should hide and second one should take its place.

ITERATION 1: Not using keys:

PieChart

ITERATION 2: Using ValueKey:

PieChart

Experiment: Using UniqueKey:

PieChart