I just started learning Dart and Flutter and for starting, I would like to develop an application that acts as a server (to which we send messages from telnet
).
So at the moment, I have the two following classes:
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => new _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
List<String> _messages = <String>[];
...
}
So as I said, the app will run as a server. I want to update the list _messages
every time the server receives a message.
I would like to update it from another class, let's call it Server
, from which I call i.e. HomeScreen.addMessage(String message)
and I would also like to keep _HomeScreenState
private.
I've searched a lot of time for a solution but didn't find anything suitable for my needs.
Could you guys help me?
Many thanks in advance!