Skip to content

Instantly share code, notes, and snippets.

@ashraf267
Created June 8, 2022 16:03
Show Gist options
  • Save ashraf267/98a8458b491fe82c97c7381b08657dc7 to your computer and use it in GitHub Desktop.
Save ashraf267/98a8458b491fe82c97c7381b08657dc7 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool? isPressed;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.blueGrey,
body: Center(
child: Row(
children: [
Expanded(
flex: isPressed == true ? 2 : 1,
child: TextButton(
onPressed: () {
setState(() {
isPressed = true;
});
print('firstDice: $isPressed');
},
child: Image.network('https://raw.githubusercontent.com/londonappbrewery/dicee-flutter/master/images/dice1.png'),
),
),
Expanded(
flex: isPressed == false ? 2 : 1,
child: TextButton(
onPressed: () {
setState(() {
isPressed = false;
});
print('secondDice: $isPressed');
},
child: Image.network('https://raw.githubusercontent.com/londonappbrewery/dicee-flutter/master/images/dice2.png'),
),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment