Created
August 1, 2020 19:50
-
-
Save ArcticZeroo/e7a5370413350609ab4e00d78711f820 to your computer and use it in GitHub Desktop.
Flutter IconButton Splash 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(App()); | |
} | |
class App extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) => MaterialApp( | |
theme: ThemeData.dark(), | |
home: TestWidget() | |
); | |
} | |
class TestWidget extends StatefulWidget { | |
@override | |
_TestWidgetState createState() => _TestWidgetState(); | |
} | |
class _TestWidgetState extends State<TestWidget> { | |
bool enablePress = true; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Row( | |
children: [ | |
IconButton( | |
icon: Icon(Icons.remove), | |
onPressed: enablePress ? () { setState(() { enablePress = false; }); } : null | |
), | |
SizedBox( | |
width: 24 | |
), | |
IconButton( | |
icon: Icon(Icons.add), | |
onPressed: enablePress ? null : () { setState(() { enablePress = true; }); } | |
) | |
] | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment