opened 03:47AM - 07 May 22 UTC
closed 10:17AM - 07 May 22 UTC
i want to bind functions as describe in code please resolve the issue
import 'p…ackage:flutter/material.dart';
class WindowListener{
final Function()? Add;
final Function()? Delete;
WindowListener({this.Add, this.Delete,});
}
class Buttons extends StatelessWidget {
const Buttons({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(children: [
// here want to bind windows listner add function
IconButton(onPressed: (){}, icon: Icon(Icons.add)),
// here want to bind windows listner add function
IconButton(onPressed: (){}, icon: Icon(Icons.delete)),
],);
}
}
class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key);
@override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
@override
Widget build(BuildContext context) {
return
Scaffold(body:
Column(children: [
Buttons(),
ChildPage()
],),);
}
}
class ChildPage extends StatefulWidget {
const ChildPage({Key? key}) : super(key: key);
@override
State<ChildPage> createState() => _ChildPageState();
}
class _ChildPageState extends State<ChildPage> {
// here if add function call then do this
void AddFunction()
{
print('Add button clicked');
}
// here if Delete function call then do this
void DeleteFunction()
{
print('delete button clicked');
}
@override
Widget build(BuildContext context) {
return Column(children: [
Text('This is child page')
],);
}
}
<!-- Thank you for using Flutter!
If you are looking for support, please check out our documentation
or consider asking a question on Stack Overflow:
* https://flutter.dev/
* https://api.flutter.dev/
* https://stackoverflow.com/questions/tagged/flutter?sort=frequent
If you have found a bug or if our documentation doesn't have an answer
to what you're looking for, then fill out the template below. Please read
our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->
## Steps to Reproduce
1. Execute `flutter run` on the code sample
2. ...
3. ...
**Expected results:**
**Actual results:**
<details>
<summary>Code sample</summary>
<!--
Please create a minimal reproducible sample that shows the problem
and attach it below between the lines with the backticks.
To create it you can use `flutter create bug` command and update the `main.dart` file.
Alternatively, you can use https://dartpad.dev/
which is capable of creating and running small Flutter apps.
Without this we will unlikely be able to progress on the issue, and because of that
we regretfully will have to close it.
-->
```dart
```
</details>
<details>
<summary>Logs</summary>
<!--
Run your application with `flutter run --verbose` and attach all the
log output below between the lines with the backticks. If there is an
exception, please see if the error message includes enough information
to explain how to solve the issue.
-->
```
```
<!--
Run `flutter analyze` and attach any output of that command below.
If there are any analysis errors, try resolving them before filing this issue.
-->
```
```
```
```
</details>
<!--
Consider also attaching screenshots and/or videos to better
illustrate the issue.
You can upload them directly on GitHub.
Beware that video file size is limited to 10MB.
-->