title: Separating UI and Logic in Flutter
body: <p>Normally, I use a separate class with an object declared on the top of the widget. I wish to know what is the problem with that architecture.</p>
  <p>I came across an entire package in Flutter, WidgetView, which needs to declare a dependency, then make a state object, and then do the same thing.</p>
  <p>Why not just a simple class for achieving the same. like below</p>
  <pre><code>class NewAccountComponent extends StatelessWidget {  
  final NewAccountComponentLogic logic = NewAccountComponentLogic();
    @override
    Widget build(BuildContext context) {
      return AlertDialog(
        title: Text('Enter a Unique Account Number'),
        titlePadding: EdgeInsets.all(20.0),
        content: TextFormField(
          controller: logic.controller,
              onPressed: () =&gt; logic.clearTextFormField(),
            ),
          ),
  }
  class NewAccountComponentLogic {
    static String accountNumber;
    static bool existsAccountNumber;
    TextEditingController controller = TextEditingController();
    clearTextFormField() {
      controller.text = '';
      accountNumber = '';
  }
  </code></pre>