A couple tries with flutter today
Tags: flutter, dart, programming
Published: 2021-09-13 07:07:48

  Pulled up a tutorial and made a flutter app today. Took some time to get used to the "widget" style coding form used with dart. Will practice some more on it. Some sample code, which reminds me of CSS for some reason, of dart from earlier today : 


```
Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blueAccent,
      body: Center(
        child: Padding(
          padding:const EdgeInsets.symmetric(vertical: 30),
          child: Center(
            child: Padding(
              padding: const EdgeInsets.symmetric(vertical: 30),
              child: Column(
                children: <Widget>[
                  Text('Measurement',style: TextStyle(
                    fontSize: 40, color:Colors.white, fontWeight: FontWeight.w700
                    ),),
                  Text('Converter',style: TextStyle(
                      fontSize: 40, color:Colors.white, fontWeight: FontWeight.w700
                  ),),
                  Padding(
                    padding: const EdgeInsets.symmetric(vertical:20, horizontal:40),
                    child: TextField(
                      onChanged: (text){
                        var input=double.tryParse(text);
                        if(input != null)
                          setState(() {
                            userInput = input;
                          });
                      },
                      style: TextStyle(
                        fontSize: 20, color: Colors.black
                      ),
                      decoration: InputDecoration(
                        filled: true,
                          fillColor: Colors.grey[300],
                          hintText: 'Enter Your Value',
                          border: OutlineInputBorder(
                            borderRadius: BorderRadius.circular(20)
                          )),
                    ),
                  ),
```

The variable and method declarations are similar to what I'm used to with Swift, but these "widgets" will take some time to get familiar with. From what I've come across, the idea is that your app screen is a "canvas", so you can be more specific about what's displayed. 

The app is a measurement converter, which worked pretty well. Customized it to what I wanted displayed. 

A couple things to get more familiar with :
* Wrappers for items within widgets.
* The order in which widgets are built. 
* How to further customize input within widgets. 

Here's what it looks like so far : 
![Screen Shot 2021-09-12 at 11.56.42 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npu0veu45mrjsh4uo31n.png)

I was thinking of doing it through Android Studio, but ended up doing it through IntelliJ, which took some calibrating on the SDK side. It finally went through after refreshing the Android SDK a couple time. Had to refresh the SDK in order for the Android emulator to load and display the flutter app after running it. 

Although the "widget" style looks cumbersome, I like the idea of not having to code in two different pages like Android Studio : Java for functions and XML for layout. The added benefit being this can also create an iOS app. So while the "widget" approach may make the primary file look more bloated, there's only one to deal with.