'show List Tile after clicking on button flutter
I have an Elevatebutton where I want to do that when I click on it, I can see a listTile displayed and after I click on another button the listTile will disappear. I have the code written like this:
ElevatedButton(
onPressed: ( ) {
setState(() {
ListTile(
leading: Icon(Icons.add),
title: Text('GFG title',textScaleFactor: 1.5,),
trailing: Icon(Icons.done),
);
});
},
child: Text('button1'),
style: ElevatedButton.styleFrom(shape: StadiumBorder()),
),
but even when I click on the button I do not see the listTile. How do I fix this? Can someone help me?
Solution 1:[1]
Try below code:
Decalre bool variable
bool buttonPressed = false;
Your Widget:
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
buttonPressed
? ListTile(
leading: Icon(Icons.add),
title: Text(
'GFG title',
textScaleFactor: 1.5,
),
trailing: Icon(Icons.done),
)
: Container(),
ElevatedButton(
child: Text("Show Widget"),
onPressed: () {
setState(() {
buttonPressed = true;
});
},
)
],
),
Solution 2:[2]
How can I get this ethereum to my admin account?
Based on the context of the question (the ETH is paid to the token contract - not to a DEX pair contract), I'm assuming you have a custom buy function.
You can expand this buy function to use the transfer() method of address payable to transfer the just received ETH to your admin address.
pragma solidity ^0.8;
contract MyToken {
address admin = address(0x123);
function buy() external payable {
// transfers the whole ETH `value` sent to the `buy()` function
// to the `admin` address
payable(admin).transfer(msg.value);
// ... rest of your code
}
}
Contract bytecode is immutable (with some edge case exceptions), so in order to perform the change, you'll need to deploy a new contract - can't expand the already deployed contract.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ravindra S. Patil |
| Solution 2 | Petr Hejda |
