Categories
Note to Self

How To Tell Your Friends You Started A Blog

I started a blog, obviously, but it’s weird telling my friends that I’m writing blog posts that I expect people to read. It’s like baking enough cookies for a party of 12, but it’s just you and me. I made too many cookies, or did I? 

Too many cookies bro
Guess I’m gonna just have to eat all of these

I’m telling people I’m starting a blog because I think it’s great practice to articulate my thoughts, but if I may go deeper then that, it’s because I can communicate through my higher self. 

Everyone Has A Higher Self

I’m not talking about my high self, when I smoke a bunch of weed and forget the sentence I just thought up, I’m referring to the subconscious. The elusive part of myself that is always retrieving data, storing it and guiding my intuition or my better nature. Not everyone’s subconscious is the same, so before you roll your eyes and think I’m just spouting out bull shit in my new blog I want to say that it’s a real guiding consciousness in our lives that we hardly are in contact with. 

Writing Puts Me In Contact With The Gods

Hey
Thank you for this flow

That sounds extreme, and it’s meant to, because well I’m writing a blog and I’m expecting you to be this far along and still holding your attention. However, if you’ve got an open mind, then you can imagine what I mean. The more freely you articulate your thoughts on paper or in a digital note pad, the more fluid wisdom just pours out. It’s almost like you’re accessing a part of your brain that you in 99% of your day you completely ignore. When I sit down and start to write about anything, I begin to type through this person that is talking to me, my conscious every day self. 

Kyle Meet Kyle 

We are constantly receiving information from all around us, like an antenna tuned into to a radio station. I believe that when I begin writing, I’m tuning the dial to this subconscious Kyle that doesn’t bother with greetings, it’s just like, “Duh, where have you been? You should go for a walk.”

I’m happy that I can talk through you Kyle, and I’m excited that I can wrap my mind around what this is now, I will go for a walk, thanks. 

Go for a walk
Go for a walk.

Be A Subscriber

I’m not shy like I used to be, so I’m going to directly ask you to subscribe to this blog. It’s full of important Me stuff, and information that you might be able to get some use out of as I continue to write.

I want to close this by saying that in order for me to keep this blog going, I’m going to have to remember one thing. Do not write for an audience, write for yourself. This is a blog intended for the conscious Kyle you see walking around society, skating down the street, playing a tune on a guitar. That Kyle needs some guidance and reassurance that he is on the right track, and to just relax, don’t stress, breathe, and make some damn money so you can get the hell out of Los Angeles already! 

Thanks for being a subscriber, if you have any comments leave them below, I know you have to have Facebook to leave a comment, so if you’re against Facebook, send me a DM on Instagram (A Facebook Company) @kyleknob or on Twitter @kylesshortcuts, thank you. 

Categories
Note to Self

How To Travel In A Pandemic

Pandemic Traveling
Keep it together.

Like you, I thought about all the dangers of traveling before I made my decision to get on a plane. So this is how I made my decision. Like all big decisions I weigh the pros and cons. In my case, I was offered a free flight from Los Angeles to Philadelphia to go to Woodward Skate Camp with my good friends at Dogwood Skateshop. What that meant to me was fresh air, a break from reality, and a very cost effective trip. I compared all these great things to the pandemic. 

Pros & Cons

I don’t think anyone can tell you how to make a decision to travel, but it is your responsibility to feel like whatever your decision you make is the right one. There are some reasons why you shouldn’t travel, like if you are a naturally anxious person about your health, or you’re a hypochondriac. In this case I recommend you stay home if you’re just going to stress about covid the entire plane ride. However, if you’re a little worried but think that your trip will alleviate some stress then go somewhere relaxing. The chances of you catching covid if you’re a relatively healthy person and you take as many precautions as you can, are slim. 

A lot of the fear surrounding covid is toxic and is causing way too much stress which actually inhibits your immune system.

Breathe through your nose deeply.

Prioritize Relaxation

Vitamin D is so key.

Unless of course you are traveling because of an emergency, make sure you’re getting enough time to relax out in the sun. The sun should be one of your priorities, take your shirt off, soak in as much Vitamin D from the sun that you can without burning of course. Your immune system will thank you. Breathe in some fresh air too and drink some clean water. Remember the elements: Earth, Wind, Fire and Water. Put your feet in some soil, breathe fresh mountain air, soak in some warm sunshine, and drink some fresh spring water. Visit findaspring.com to see where your nearest spring is at. Not that I went and got spring water on this trip, but I wish I did, I just drank plastic bottled water. I don’t know what’s worse, plastic bottled water or tap water?

Be Grateful for What You Can Do

In the end, this trip is about getting out of your routine and being with friends. This is such a strange uncertain time that I can’t really be certain if I can have many more of these trips, I don’t like to think too dismally, but it’s hard to know for sure, so cherish what you have right now, and what you can do. Flights are cheap, if you’re far from your family and your friends go visit them, tell them you love them, because you don’t know if you’ll ever get the chance to do that in person again. Be safe and be prepared for any scenario. If you have comments, want to call me an idiot or something, leave them below or reach out to me on Instagram @kyleknob.

Categories
Programming

Programming Until You Get Headaches

I been following along with my instructor Angela Yu on Udemy and I have been enjoying how clear and concise she is, however I really wish there was more explanation about the syntax of the Dart programming language. Like why use semi-colons instead of commas, why use curly braces here and not there etc. Maybe these are things I will look into when I find time, but it’s really testing my memory skills, and that is the sole reason I decided to get Lion’s Mane mushroom. Lion’s Mane is a medicinal mushroom that helps with memory amongst other things, and when taken with a small micro dose of psilocybin I find that installing those memories is much more easier. I do recommend you micro dose, there are amazing benefits, however I am not your personal advisor and if you are susceptible to intense anxiety, paranoia or psychosis you might not want to experiment with it and instead take more notes. 

Function Inputs or Arguments

To remind you, you create a function with a void keyword:

void nameFunc(){} — in this function’s empty parentheses () you can add data like you would a variable. For instance:

void greet(String personToGreet){} —  this creates the opportunity to use personToGreet in your function like so:

print(‘Hello $personToGreet’) — now if you’re going to call on this function you would need to add it to your void main(){} like so:

void main (){

greet(‘Kyle’);

}

This main part of your function will look between your parentheses in your greet() function you created:

void greet(String personToGreet){ 

print(‘Hello $personToGreet’);

}

This is how you pass data when you CALL on the function greet(‘Kyle’);

I’m not entirely sure how I’m going to use this in the future, but I’m sure there is a reason why she had told us about this. In this module I’m building out the Xylophone app, installing a package I found on the Dart packages website called Audio Players, importing it into my main.dart file and calling on it in my pubspec.yaml file to load sound files from my local assets folder. 

Building out this app was a small tutorial on how to pass an integer into the function that plays the sound when the button is clicked. 

void playSound(int soundNumber){

  final player = AudioCache();

  player.play(‘note$soundNumber.wav’);

}

When I press the button it calls on this function that is ran with:

playSound(1) or playSound(2) — replacing the number of my sound file in my assets folder to play a different note when another button is clicked. 

Making Use of 3 Types of Functions

Functions that start with void() have NO output, but can assume an argument between the parentheses that is a variable. If you don’t need an input it’s a function that just runs a series of steps. If you add an input then you can use that input variable in your function. The third type of function has an output and you call this by the data type you wish to output with this function. In the case of the Xylophone app we use a function to output an Expanded widget and use the inputs of the buildKey() function to specify the color of the Expanded() widget and the sound file to play when clicked, with a variable titled soundNumber, like so: 

Expanded buildKey({Color color, int soundNumber}){

  return Expanded(

    child: FlatButton(

      color: color,

      onPressed: () {

        playSound(soundNumber);

      },

    ),

  );

}

I emboldened the parameters that cannot be given a unique name to illustrate how this function is built. Expanded is the widget we are returning so we need build the function starting with Expanded and follow that with the name of the function we will later call, in this case buildKey(), but notice how inside these parentheses we add curly braces: buildKey({Color color, int soundNumber}) — the data type we are going to change is the Color property, and the data type of int that will be specified in the previous variable called soundNumber.

The curly braces are necessary only when we are creating a function that needs to specify the name of the data we wish to change. For instance we are going to need to specify the color when we call on the buildKey method like so: 

buildKey(color: Colors.red, soundNumber: 1),

buildKey(color: Colors.yellow, soundNumber: 2),

buildKey(color: Colors.blue, soundNumber: 3),

buildKey(color: Colors.purple, soundNumber: 4),

buildKey(color: Colors.orange, soundNumber: 5),

buildKey(color: Colors.teal, soundNumber: 6),

buildKey(color: Colors.pink, soundNumber: 7),

We are basically telling this buildKey function to return the Expanded widget, that has a child of a FlatButton, who’s color will be defined when we use the function (hence the Color color input when creating it), and when you press that button it’s going to run the function playSound we previously created that takes an input of an integer data type we called soundNumber. So that when we use buildKey(color: — we are telling it to look for the variable called color in the function color: color — built into the input of the function buildKey({Color color — the property of Colors.red, blue, green etc. will be specified by us when we call the function buildKey(color: Colors.red, soundNumber: 1) —  we then specify the soundNumber variable with an integer of 1 or 2 etc.

There’s a lot to wrap your mind around, but when you dissect the creation of the function it becomes logical, computers aren’t really a mystery, they just run off of logic and use keywords to know what you’re trying to tell it. So look at these functions, tinker around with the inputs, try to understand the syntax and why it’s written the way it is. We’re practically trying to imagine if we were a computer how this would translate to us in a clear way. It takes practice. 

import 'package:flutter/material.dart';
import 'package:audioplayers/audio_cache.dart';

void main() => runApp(XylophoneApp());

class XylophoneApp extends StatelessWidget {

  void playSound(int soundNumber){
    final player = AudioCache();
    player.play('note$soundNumber.wav');
  }

  Expanded buildKey({Color color, int soundNumber}){
    return Expanded(
      child: FlatButton(
        color: color,
        onPressed: () {
          playSound(soundNumber);
        },
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              buildKey(color: Colors.red, soundNumber: 1),
              buildKey(color: Colors.yellow, soundNumber: 2),
              buildKey(color: Colors.blue, soundNumber: 3),
              buildKey(color: Colors.purple, soundNumber: 4),
              buildKey(color: Colors.orange, soundNumber: 5),
              buildKey(color: Colors.teal, soundNumber: 6),
              buildKey(color: Colors.pink, soundNumber: 7),
            ],
          ),
        ),
      ),
    );
  }
}

Headaches Be Gone

Don’t let the headache of learning control your attitude around learning, I must remember to have fun at this every step of the way and take breaks if I catch myself getting too serious. Remember to laugh at your own incompetence, you will learn, but you will learn at your own pace. If you have any questions or comments leave them down below or reach out to me on Instagram @kyleknob

Categories
Note to Self

How to Be More Creative

Lot’s of the artists I admire have one thing in common: they all have their own unique style. Think about that, every artist that you look up to has very little resemblance to any other artist in their space, but yet I’m trying to be more like Warhol or Bowie or something. 

Making Art Is Over Rated

Making art is overrated
What to make?

When I do my best work, I’m not telling myself, I’m going to make art today. I’m letting myself succumb to the emotions I’m undergoing at that moment. My emotional state at any given moment translates through the art I’m making. So I’m not consciously telling myself to go make art, I’m allowing my emotions to be constructed into whatever medium I choose. So don’t make art, be aware of your emotional state and translate it. Don’t let that confuse you, I’m not saying don’t make art, I’m saying, make art that means something to you, not to who ever your potential audience is. 

The Difference Between Potential and Perfection

When I have a new idea in my head I envision it being flawless, and my expectation is set so high that when I start on that project I’m struggling with what I can physically create compared to what I’m mentally picturing. This expectation is the killer of creativity, I’ll stop myself right in my tracks after undoing one line I drew 3 times. 

Through years of dealing with these high expectations I’ve become so aware of the mental torture it causes that I just started drawing in whatever style comes naturally out of my untrained hand. The act of letting go is a spiritual practice, and before I start boring you with some spiritual reading I want to say that many of our expectations are built in the version of you that presents itself to others, or the ego. Once you can realize you have no control over how others view you, the creative mind opens up like a flower in spring. 

Be you
Let it go, you’re not anyone but you.

Your potential is not measurable, and perfection though it seems possible is never achieved. The sooner you can accept this, the more you will allow your creativity to run through you like the blood in your veins. 

Overcoming Criticism 

I will always be talking about overcoming criticism as an exercise to overcome it myself. Writing these blogs actually help me more than you think. I’m telling myself, “This is a practice of becoming more honest with myself and more open with others.”

You won’t be able to turn off the fear of showing your own art to someone, but you can learn to dance with it. I love this term coined by Seth Godin, the marketing guru. 

Dance with your fear, don’t run from it.

The idea is that the fear your feeling comes from part of your brain that is there to save us from being injured or killed in the wild by maybe a bear or a mammoth or something, but in this modern age where fear presents itself before public speaking or in this case sharing your art with a group or a friend, there’s no life threatening risks. Your brain might be making you feel like there are, but you’re misinterpreting what it’s trying to tell you. It’s saying, you’re uncertain of what’s about to happen because it might make you uncomfortable. 

Fear of Being Uncomfortable

You’re debilitating fear of being uncomfortable is controlling your progression. We all have dreams of becoming successful at what we love to do, and only some of us will make it according to how willing we are to be uncomfortable. Your progression really relies on listening to your brain when it feels scared and having the ability to tell it,

“Thanks for the alarm I will do exactly what you’re trying to prevent me from doing.”

I hope that after reading this you got some insight on how to be more creative. It’s not so hard but it’s a practice that I wish I started when I first began creating art. I still struggle with my creativity and you will too. This is just a reminder to you that everyone deals with the trouble of accessing their true style, techniques or voice. The great harbinger of art is listening to your fears and understanding how it corresponds with your ego. Until you find a good relationship with yourself and truly love your mistakes, you will be blocking the emotion needed to progress as a unique artist. 

Categories
Note to Self

Why I’m Allowing Myself To Be More Vulnerable

On my way to freedom, in this day and age

I’m on this journey for freedom, a lot like the epic tales I’ve heard of people escaping war torn lands across the world to come to America or something, but this is a more modern version of those stories. I’m seeking freedom in many alternative ways, like many of my friends are. I’ll start with financial freedom.

As soon as I get my bag, I’m fleeing LA

Financial Freedom

All of us have a relationship with money and if you’re like me, you’re so tired of hearing anything about investing, career paths, or the future of retirement. I told myself to live in the moment, focus on what I need now, and not dwell on where I’m at 40-50 years from now. Until the pandemic hit, I was riding this wave that was never going to crash into the shore, but that all changed.

This wave won’t crash.

The Pandemic Effect

When my brother was laid off from his work as a chef and I started to work from home, a profound sense of fragility weighed over us. I’m speaking of the uncertainty of employment, how extremely reliant I am on my job to pay me well enough to eat, pay rent, drive a car, and be connected to the internet. The alarm was going off in my head, “I’m not equipped to handle a catastrophe.”

I work in design and have the good fortune of being able to work from home, but my brother and roommate, is relying on unemployment to get him through this time. When “The News” said they were going to slash unemployment benefits by $600, it got real worrisome. At the time of writing this I think more than 30 million Americans are unemployed. That’s around 530 Dodger stadiums filled with people relying on benefits that are now cut, possibly losing homes and businesses with families to feed and debts to pay.

What the pandemic showed me was how incredibly vulnerable my life is. I’m so grateful to have done this and that in my past that brought me to this and that right now, however I’m still worried and I still can afford groceries!

These aren’t cheap.

I’ve come to the conclusion that I need to learn how others are making money online, working from anywhere so that I’m financially reliant on my capabilities not someone else’s. I need to try new things and make calculated business decisions that can get a product that’s in demand on the market and sell it, how to take an app idea, learn to develop it, and monetize it (readySketch), how to write quality content to drive readers to this blog, how to be myself in front of the camera to teach the skills I have in design, photo and video, and how to communicate my vision of the future that so many of my friends are striving toward, an off the grid, sustainable homestead.

Should I be doing this?

Freedom from Self Criticism

Up until now I ridiculed people for being personalities on YouTube or shooting selfies because of my own insecurities. A lot of us use our own insecurities to put someone down for doing something we wouldn’t do ourselves. I had a lot of self reflecting I’ve done because of the Pandemic Effect, so I needed to explore what I could possibly offer to you, the reader, that drives value to my content, and it was easy. 

I need to share with you my gifts of what I’ve learned in my unique circumstances, in my own way that differs from how others are sharing their gifts. Embarking on this comes with facing my fears of being on camera, being read enough, being important enough, being successful or disciplined, having a worthy point of view, being knowledgable enough, etc. There’s too many insecurities to name, and I’m certain I’m suppressing more than that. 

Getting Over “It”

I’m having a difficult time actually making the transition from work and procrastination to work and progressive action. I need to make the time if I am serious, and I am. I believe that I’ve ridden these waves far too long to not know how this current of mind flows. Discipline is key to the success of any project or business, and jeez, I lack it so badly. 

This is a much better use of my time.

Acknowledging you have a problem is the first step to solving that problem. I am a procrastinator. The discipline must first be enforced by myself, and I must trust this “higher self” that wants only the best of me, to guide me along on this uncertain, bumpy, exciting journey to financial freedom. 

Techniques to Practice Discipline

I’ve added a reminder to my calendar. You can do that right now, open your calendar app on your device and schedule something you want to remind yourself to do every day or every Monday (you got to ease yourself into it) and when that reminder pops up you’ll remember to get to work, or if you’re like me you’ll follow it for a few months and just ignore it for life until a pandemic or something catastrophic enough happens to eventually act on it. 

Another technique I’ve heard I think actually comes from Jerry Seinfeld, but I was clued in on it by my app development instructor Angela. Everyday you accomplish 20 minutes of the goal you set or more, you draw a line through the date of that physical calendar. You might have to buy a desk calendar, but if you’re serious about discipline you might as well. 

Buy a desk calendar right now.

You’ll be so inclined to continue to draw that line through the days that no matter how much you feel like procrastinating, you’ll want to do at least 20 minutes to continue drawing that line through the month. I’m just starting to do that now, so I’m no seasoned veteran of this technique, it just sounds good.

I’m gonna achieve this goal, because this snake I’m drawing must not end.

Chasing Freedom Must Be Fun

For me, if it’s not fun I won’t bother learning or making anything, so in order to get things done I create the fun. I must, no matter how mundane and brain consuming the tasks are,   

I must make fun of it some how, whether actually laughing at my own incompetence or just being absurdly creative with it. 

Fun must be fuel to achieve great things. It’s what gave me all the skills I have now, and what will give me everything new I learn from here on out. 

My advice to my younger self, or to you my reader, is to not allow your fear of being vulnerable to the public determine how you proceed through life. The people I admire are the most vulnerable, open, and disciplined people in the world.  I will not get to achieve the freedom I seek by being afraid of my own insecurities. Don’t be sorry to anyone for who you are.  

I hope that I can inspire you to follow your passions to fullest extent, I’m trying to inspire myself constantly. Remember to have fun, be resourceful, ask questions and be yourself. It’s easier said than done, but you will not be mad at yourself for trying, and if you’re disciplined and consistent, a few years from now writing blogs, making videos, learning new skills, you’ll be surprised by what you achieved.

If you want some help with your journey feel free to leave a comment below or reach out to me on Instagram @kyleknob

Categories
Programming

Function’ Flutter Confusion!

I thought I knew a thing or two about functionality and how Dart code works until I took a weekend off of coding and came back to it. Once I tried to code using my memory of Cards and ListTiles I realized I needed more practice. 

Practice Practice Practice

Coding isn’t as fun as playing guitar or skateboarding or something like that, since there’s no immediate reward. Well I suppose there is, it’s just not as immediate. What I’m trying to say is that when I’m coding it’s about the repetitiveness of it that will help me remember it, just like writing a song or doing a kickflip. My brain wants to speed through everything, but it’s the time and the work I put into it, just like everything else, that will allow me to become a better programmer.

Stateless and Stateful Widgets

I had an epiphany a moment ago when I coded a Magic 8 Ball app in Angela’s class about how Stateless and Stateful widgets interact. It looks as though the Stateless widget is where the Material App, AppBar, Scaffold and body: are held, but until now I didn’t realize that the body property holds the name of the Stateful widget. In the case of this Magic 8 Ball app, the body: property holds body: Ball(), the name of the Stateful widget and class I define to make the app function, or change state.

Class or Widget or Both?

It seems to me that the name of the widget is defined by using a class. I name my Stateful widget Ball and it changes the name of the state as well, for example:

class Ball extends StatefulWidget {

  @override

  _BallState createState() => _BallState();

}

class _BallState extends State<Ball> {

  int ballNumber = 1;

  @override

  Widget build(BuildContext context) {

    return Center(

It’s in between the class _BallState extends State<Ball> { curly braces that I define my programs variables and functions. Here, I created a variable called ballNumber and I set it to 1.

I am returning the rest of my apps body in the return Center(), portion of this Stateful widget. Which is loaded in my Stateless widget by just calling on the name of the Stateful class I titled Ball:

class BallPage extends StatelessWidget {

  @override

  Widget build(BuildContext context) {

    return Scaffold(

      backgroundColor: Colors.lightBlue,

      appBar: AppBar(

        backgroundColor: Colors.blue,

        title: Text(‘Ask Me Anything’),

      ),

      body: Ball(),

    );

  }

}

Should I stop programming?

The name of this Stateless widget is called BallPage, and a lot like how I call on my Stateful widget in my body property I do the same with my Stateless widget in the runApp==> Material App widget, like so:

void main() => runApp(

      MaterialApp(

        home: BallPage(),

      ),

    );

I’m telling Dart, run this app that’s built with your MaterialApp framework and the contents of this app can be found in the following Stateless widget titled, BallPage. With your home: property you will find home: BallPage(), which makes sense when you analyze how each widget inherits the code preceding it. 

So remember that the Stateless widget holds the body of your Stateful widget, and the Material App needs to load both of those by calling on the name of the Stateless widget you define with the home: property. Make sense? Maybe re-read that a few more times. It’s computer language, you begin to realize how meticulous computer languages are. 

Stateless widgets hold no functionality and Stateful widgets do. Your Stateless widget needs to know about your Stateful widget with the body: property and your Stateful widget needs to return the Center or Container widget tree of the functional app you’re creating, got it?

import 'package:flutter/material.dart';
import 'dart:math';

void main() => runApp(
      MaterialApp(
        home: BallPage(),
      ),
    );

class BallPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.lightBlue,
      appBar: AppBar(
        backgroundColor: Colors.blue,
        title: Text('Ask Me Anything'),
      ),
      body: Ball(),
    );
  }
}

class Ball extends StatefulWidget {
  @override
  _BallState createState() => _BallState();
}

class _BallState extends State<Ball> {

  int ballNumber = 1;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: FlatButton(
          onPressed: () {
            setState(() {
              ballNumber = Random().nextInt(5) + 1;
            });
            print(ballNumber);
          },
          child: Image.asset('images/ball$ballNumber.png'),
         ),
    );
  }
}

If you have any questions leave a comment below or reach out to me on instagram @kyleknob

Categories
Programming

Flutter Functionality & Me

I’ve learned a lot since my last entry, and it is all making very good sense. Since my last module with Angela I’ve become a bit more adapted to writing in Dart. I’m feeling pretty good about it. I suspect this is what I miss about being a student in conventional school. You’re introduced to something you want to know more about, you’re told to study that subject, you make notes that you can understand as you study, and you go over that for an hour a night until the test, you pass the test because it’s all so familiar, you get a good grade, you’re excited to tell your parents, and experience for the first time the pride in learning new things. 

Before I look at my notes, I’m going to try to remember some of the new things that I think are important for you to remember.

  1. Start new functions with void. Like —  void nameFunc () { //do something}; — remember the syntax, () and {};
  2. Variables can be called by it’s data type instead of calling out var use the data type to call it out — int = 12; — string = ‘Hello’; — remember the syntax = and close with ; 
  3. Card widgets are formatted for a Icon leading horizontal box, use can make children [ ] within the widget that hold ListTile (), — ListTile widgets are followed by leading: property for Icons.icon, a title: property for Text(‘Some Text.’ style: TextStyle(fontFamily’Sans’),), — and a trailing: image or icon — wrap it all in a Padding() widget for some padding
  4. Images can be called using child: Image.Asset(‘images/name.png’)— with string interpolation you can use the $myVarName to pass in the data of the var — Image.Asset(‘images/$myVarName.png’),
  5. Stateful widgets are for functionality, stateless are for displaying content only — in the class page state method you want to call out your vars and functions — in the build method is where you hot reload your app and return a widget to begin the widget tree ie. return Center (),
  6. An Expanded() widget in a Row() is meant to take up the entire width of the Row — Use Expanded widget instead of container to fit to width of any size device
  7. FlatButton(), is used to wrap an object in a button. It needs to include onPressed(){ } to tell it what to do when you press the button. This is where you can check to see if it’s working with a print (‘Hello’), statement — you can’t really update the state of the button without putting setSate((){} inside of onPressed(){ } — setState tells the app to update what’s on the page when button is pressed.
  8. Import ‘dart:math’; at the very beginning of your code to use the math library, I used this so far to call a Random function to my variables — varName = Random().nextint(max) + 1; randomizes the image in the images/ asset folder according to a number from 1 – 6, so I replace the max with a 6 and + 1 because it counts from zero

I only looked at my notes when I started to forget around number 6, but writing down notes and writing it out for you in a blog really helps cement the knowledge in my brain. If I keep this up I’ll be a pretty resourceful developer. I’m excited to learn more, but I’m going to study the layout of this code some more and I hope that you’re excited to learn more as well, us beginners need to help each other. I’m happy to share this journey with you. 

If you have any questions or comments leave them below, otherwise reach out to me on Instagram @kyleknob. 

import 'package:flutter/material.dart';
import 'dart:math';

void main() {
  return runApp(
    MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.red,
        appBar: AppBar(
          title: Text('Dicee'),
          backgroundColor: Colors.red,
        ),
        body: DicePage(),
      ),
    ),
  );
}

class DicePage extends StatefulWidget {
  @override
  _DicePageState createState() => _DicePageState();
}

class _DicePageState extends State<DicePage> {

  int leftDiceNumber = 1;
  int rightDiceNumber = 2;

  void diceChange (){
    setState(() {
      leftDiceNumber = Random().nextInt(6) + 1;
      rightDiceNumber = Random().nextInt(6) + 1;
    });

  }

  @override
  Widget build(BuildContext context) {


    return Center(
      child: Row(
        children: [
          Expanded(
            child: FlatButton(
              onPressed: (){

                  diceChange();



              },
              child: Image.asset('images/dice$leftDiceNumber.png'
              ),
            ),
          ),
          Expanded(
            child: FlatButton(
              onPressed: (){

                  diceChange();

              },
              child: Image.asset('images/dice$rightDiceNumber.png'
              ),
            ),
          ),
        ],
      ),
    );
  }
}
Categories
Programming

Understanding Google Flutter & Dart Programming

Each app begins with the runApp() function. It calls on the MaterailApp() Google designer framework that loads in all of the components to build an app with flutter. Using the home: property I call on the Scaffold() widget. Inside those parentheses I continue the widget tree with MaterialApp() as the father and home: Scaffold() within that.

Here I can add a backgroundColor defining it using Colors.nameofcolor you can find colors at material.io or just pick a basic color like Colors.red. Following the widget tree, beneath my background color of the entire app I use the property appBar: to call on the AppBar() widget within those parentheses I call out a title: property to use a Text() widget. Inside those parentheses I use a single quote ‘ to write my text string, in this case (‘This is a mushroom’). To call out the background color of the appBar I call it out just like I did for the Scaffold’s background. 

Now to add stuff to the body beneath the AppBar() I must remember to be outside of the AppBar closing parentheses ). Here I call on the body: property and I want the Center() widget for it to be centered in my Scaffold(). I must make it a child of the Center() widget by calling out child: property. Here I want an Image() widget. In these parentheses I tell the child: Image( that I want an image: that is a AssetImage() or a NetworkImage().

If it’s an AssetImage() I must open the pubspec.YAML file and under the assets portion of this YAML file I call out a folder I created in my flutter document called images. So pubspec.yaml looks something like:

Flutter:

  Assets:

    – images/nameofimage.png or simply leave it images/

Everything in this YAML file is read using double spaces, that’s important. So now that I called out an image in my Center() widget I can say I’ve successfully understand how the Scaffold() widget works and how things are placed in the body of the app. It’s a little tricky at first but the more I look over the code and try it from scratch over and over again, the more the syntax of dart starts to make sense. I would say this shouldn’t be too complicated once we get into interactivity by adding buttons and lists and so on, but if I continue to take my learning one step at a time, and then taking the time to understand it by writing it out to for you (my reader) I will eventually understand the concepts enough to code freely and solve issues as I run into them.

import 'package:flutter/material.dart';

//main is the start of all flutter apps
void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.black45,
        appBar: AppBar(
          backgroundColor: Colors.red,
          title: Text('This is a Mushroom'),
        ),
        body: Center(
          child: Image(
            image: AssetImage('images/cordycepts.png')
          ),
        ),
      ),
    ),
  );
}
Categories
Programming

How To Use Flutter Layout

To use hot reload with Flutter you got to put your MaterialApp in a StatelessWidget{}, you can type out stateless and select StatelessWidget. This creates a class for your app, so change the class to MyApp or the name of your app, and change the code it provides you to return the MaterialApp() widget. 

Now that you set that up, you can build your Scaffold() widget tree. So within your parentheses of your MaterialApp() use the property home: and add Scaffold() like this: home: Scaffold(), Remember to use the comma after every end parentheses so Flutter can appropriately format the code. You can change the backgroundColor: property using Colors.white, but what’s important is to remember to use the body: property to call out the SafeArea() widget. Inside this SafeArea() is where you will start adding a child Column() widget, or Row() widget.

For instance, you can call out child: Column() to start another widget tree within that Column() parent, however to add multiple Container() widgets within the child: Column(), you will need to use the children: property with square brackets. I’m not sure why we use square brackets, but we do. Within those brackets is where we call out our containers and add properties to them like size, color and text.

Use mainAxisAlignment: property to align them in your Column() thus in your SafeArea(). MainAxisAlignment.spaceevenly will space your Container()’s evenly on your screen, there’s a lot more MainAxisAlignment and CrossAxisAlignment spacing techniques you can try, Flutter helps with that when you start typing it recommends what you might be trying to do. 

The power of Flutter and its MaterialApp framework is proving to be tricky, but not impossible to understand. I’m taking my time with my lesson with Angela on Udemy to fully understand what I’m coding, and I’m taking this effort to explain to you to further cement my knowledge of the Dart language in my brain. I’m making a conscious effort not to try to speed through these lessons and it’s paying off. I tried taking her class on Swift development and was trying to learn at some unreasonable pace that eventually when it got too difficult I gave up. If you’re like me and you can spot out your weaknesses, then do what you can to approach confronting them carefully. It is easy to be disappointed, but it takes real patience and practice to learn new things, and it’s real important to have a passion project you want to create to keep the fire going. I want to learn Flutter to build out my iOSs app readySketch, so that I can bring it to Android, expand it’s capabilities, gamify it a little more and learn to monetize it. I’m a long way from getting there, but everyday I make an effort to learn Flutter I’m one day closer than before. 

I hope this helps inspire you to keep learning and go easy on yourself. Our little human minds need time to absorb new languages. Remember you’re on the right path, and app development is one of the most exciting areas to gain knowledge in. Go after it, just pace yourself. I’m only on module 2. Feel free to reach out to me by leaving a comment below or on instagram @kyleknob

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return  MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.teal,
        body: SafeArea(
          child: Container(
            height: 100.0,
              width: 100.0,
            margin: EdgeInsets.only(left:30),
            padding: EdgeInsets.all(20),
            child: Text('Goofy'),
            color: Colors.white
          ),
        ),
      ),
    );
  }
}