Skip to content

Instantly share code, notes, and snippets.

@callmephil
Last active February 10, 2024 21:10
Show Gist options
  • Save callmephil/a5b20cfd60467cce4e32ad178b433def to your computer and use it in GitHub Desktop.
Save callmephil/a5b20cfd60467cce4e32ad178b433def to your computer and use it in GitHub Desktop.
void main() {
const isDoorVisible = false;
const isClassVisible = false;
const isHazineVisible = false;
const isFaragiranVisible = false;
const isErsalPayamVisible = false;
List<bool> visibleWidgets = [
isDoorVisible,
isClassVisible,
isHazineVisible,
isFaragiranVisible,
isErsalPayamVisible,
];
print(visibleWidgets);
for (int i = 0; i < visibleWidgets.length; i++) {
visibleWidgets[i] = true;
}
print(visibleWidgets);
}
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
home: Scaffold(
appBar: AppBar(
title: const Text('Material App Bar'),
),
body: const Center(
child: MyWidget(false, false, false, false, false),
),
),
);
}
}
class MyWidget extends StatefulWidget {
const MyWidget(
this.isDooreVisible,
this.isClassVisible,
this.isHazineVisible,
this.isFaragiranVisible,
this.isErsalPayamVisible, {
super.key,
});
final bool isDooreVisible;
final bool isClassVisible;
final bool isHazineVisible;
final bool isFaragiranVisible;
final bool isErsalPayamVisible;
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
late final List<bool> _visibleList = [
widget.isDooreVisible,
widget.isClassVisible,
widget.isHazineVisible,
widget.isFaragiranVisible,
widget.isErsalPayamVisible,
];
@override
Widget build(BuildContext context) {
return TextButton(
onPressed: () {
print(_visibleList);
for (var i = 0; i < _visibleList.length; i++) {
_visibleList[i] = true;
}
print(_visibleList);
},
child: const Text('Button'),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment