searchTypeView method
Widgets themselves have no mutable state (all their fields must be final). If you wish to associate mutable state with a widget, consider using a StatefulWidget, which creates a State object (via StatefulWidget.createState) whenever it is inflated into an element and incorporated into the tree.
A given widget can be included in the tree zero or more times. In particular a given widget can be placed in the tree multiple times. Each time a widget is placed in the tree, it is inflated into an Element, which means a widget that is incorporated into the tree multiple times will be inflated multiple times.
The key
property controls how one widget replaces another widget in the
tree. If the runtimeType and key
properties of the two widgets are
operator==, respectively, then the new widget replaces the old widget by
updating the underlying element (i.e., by calling Element.update with the
new widget). Otherwise, the old element is removed from the tree, the new
widget is inflated into an element, and the new element is inserted into the
tree.
See also:
- StatefulWidget and State, for widgets that can build differently several times over their lifetime.
- InheritedWidget, for widgets that introduce ambient state that can be read by descendant widgets.
- StatelessWidget, for widgets that always build the same way given a particular configuration and ambient state.
Implementation
searchTypeView(){
return Padding(
padding: const EdgeInsets.only(top: 16.0,left: 20, right: 20.0),
child: Container(
color: Colors.black,
child: Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Row(
children: [
Container(
height: 32,
padding: const EdgeInsets.fromLTRB(12,8,12,8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset('assets/images/menu.png', height: 13,),
SizedBox(
width: 4,
),
const Text('Posts',style: TextStyle(color: Colors.black, fontSize: 13, fontWeight: FontWeight.bold),)
],
),
),
SizedBox(
width: 8,
),
Container(
height: 32,
padding: const EdgeInsets.fromLTRB(12,8,12,8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset('assets/images/gallerys.png', height: 12,),
const SizedBox(
width: 4,
),
const Text('Photos',style: TextStyle(color: Colors.black, fontSize: 12, fontWeight: FontWeight.bold),)
],
),
),
SizedBox(
width: 8,
),
Container(
height: 32,
padding: const EdgeInsets.fromLTRB(12,8,12,8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset('assets/images/friends.png', height: 12,),
const SizedBox(
width: 4,
),
const Text('Friends',style: TextStyle(color: Colors.black, fontSize: 12, fontWeight: FontWeight.bold),)
],
),
)
],
),
),
),
);
}