i have custom button widget from different file, then i create callback function it might will showing pointer from main function, when i'm running i have issues this: Issues
and this code, main layout:
import 'package:flutter/material.dart';
import './increment.dart';
void main() => runApp(MaterialApp(
home: HomePage(),
));
class HomePage extends StatefulWidget {
HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _counter = 0;
void increment() {
setState(() {
_counter = _counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
children: [
Text('Result = ${_counter}'),
SizedBox(
height: 100,
),
Inc(increment)
// ElevatedButton(onPressed: increment, child: Text('-'))
],
),
),
);
}
}
and this widget custom:
import 'package:flutter/material.dart';
class Inc extends StatelessWidget {
final Function selectInc;
Inc(this.selectInc);
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 100,
child: ElevatedButton(onPressed: selectInc(), child: Text('+')),
);
}
}
how i can solve this?