'Issues with button widgets and virtual android devices on flutter
So I am new to flutter and I was trying to tie a function to button widgets on flutter. It did not work and I honestly do not know why. I put my code in the picture and I would also copy and paste the code below.
//ignore_for_file: deprecated_member_use
import 'package:flutter/material.dart';
void main() => runApp(FirstApp());
class FirstApp extends StatelessWidget {
void answerQuestion(){
print ('Question answered!');
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('My First App'),
),
body: Column(
children: [
Text('The question!'),
RaisedButton(child: Text('Answer 1'), onPressed: answerQuestion,),
RaisedButton(child: Text('Answer 2'), onPressed: answerQuestion,),
RaisedButton(child: Text('Answer 3'), onPressed: answerQuestion,)
],
),
),
);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
