Building a Mine Sweeper Game using Dart's Flutter Framework (Part 2)

in #utopian-io6 years ago (edited)

What Will I Learn?

  • You will how to model the state of a minesweeper application with booleans
  • You will how to break code into binary solutions in a Flutter project
  • You will how to use random numbers to generate random elements for a two dimension list in Dart
  • You will learn how to use Unicode characters and codes in Dart Strings and Flutter Widgets

Requirements

Difficulty

  • Intermediate

Description

In this Flutter video tutorial, we continue making the Minesweeper game. Having built out the basics of our UI and state, we can create more specific UI widgets to model how our tiles should look when they have been** pushed or flagged**. This includes, tiles that have numbers on them, tiles that have nothing on them, tiles with mines in them and tiles that are closed. We also look at how we can model the two dimensional list of our board using Boolean values. In this way we can generate the mines for our application in a random manner.

We split our problem into binary solutions. Tiles with mines versus tiles with out mines and Tiles that are open versus tiles that are closed. For the first binary problem, we create a new two dimensional list with eighty one elements in it. This list contains all false values at its initialization. We then use a random number generator to intersperse true values into the two dimensional list which allows us to model when we have a mine on a tile (when its true) versus when we do not (when its false).

For our second binary problem, we create two new stateless widgets to model our closed and opened tile states. When the tiles are closed, they can have a flag on them or they can have nothing on them. We use two different containers to make the closed tiles look three dimensional. When our tiles are open, they can have a number, a mine or nothing in them. We add a unicode value to represent our flag and mines and we flatten out the open tiles.

The source code for this project can be found here

The freeware minesweeper game that we keep referring too can be found here

Video Tutorial

Related Series Tutorials

Projects and Series

Stand Alone Projects:
Calculator Application
Movie Searcher Application

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. Excellent tutorial @tensor. It has been approved.

I have one suggestion: Consider organizing your 'curriculum' section to make your collection of tutorials more intuitive. Perhaps you could group them into smaller collections, or organize them in some other way. You could make some Steemit posts containing tutorials of a specific sub-category then place the links into all your future Utopian submissions. This is what I had to do with my tutorial collections as my 'curriculum' list became too long. This is just a suggestion.

You can contact us on Discord.
[utopian-moderator]

Hmm well that would be one a to deal with it. I haven't encountered this problem until now, since my series on Kotlin, Rust, Elixir, Go etc haven't been as long as my tutorials on flutter. I will reorganize the list, and make it more intuitive. I have a couple of tutorials that work as "series" like this one. I also have a bunch of projects that can be grouped as such.

Edit: When I move away from flutter (which will happen at some point), I will obviously not have to worry about this huge list. I have restructured it, Please let me know if this is acceptable for this contribution and future contributions. Also, if you have any feedback let me know.

Anyways, as always, thank you for moderating my content and of course for the constructive feedback.

Hey Tensor. Sounds good.

I am pretty sure you know this, but I will mention it anyway. Make sure that all your contributions are new content developed for Utopian. Like myself, it looks like you have a lot of existing content. Utopian rules state that all content must not have been available to the public before being submitted as an official Utopian contribution. I am sure you already know this, but I like to err on the side of too much information :) So all your content needs to be new original materials.

If you have any questions about Utopian guidelines feel free to connect with me on the Utopian Discord.

Thanks,
Buckydurddle

That's a little bit of a strange topic to bring up in response to me changing the format of my contributions links. Is it because I said I was moving away from the Flutter Framework or is it because I said I had a bunch of series and projects? I meant that some of the Flutter videos could be grouped together as a bunch of series and/or projects rather then just as generic contributions which is what I did up in the post.

Even before the video age restriction rule was put into place, I did not post older videos onto Utopian except for one specific time (I wanted to use a video as context for a series I was working on). And in that one specific time, despite asking on discord and getting the OK from two different moderators, the contribution was rejected.

As such, yes I know that I am not allowed to post old videos onto Utopian. Every single one of my videos, apart from two, were created on the day that they got posted onto Utopian.

The goal of my YouTube channel is to educate people and to that end I have a strict rule about not covering topics that I myself have not used in production and in a corporate setting. Typically, I finish work in the afternoon and then I sit down to make a video. It takes me roughly 2-3 hours to record and edit the video and then another hour or so to post it onto YouTube, Utopian and put up the code on GitHub. This is the workflow that I follow, and most of my videos are basically just live coding sessions so its not that difficult to come up with ideas for content to produce about 5-6 times a week.

I do not plan to post any of my older videos onto the Utopian platform, nor do I plan to re-tread over the same content that I have already posted; unless the technology has drastically changed and even in those instances, I would make sure to add enough new information to make the video worth the time of the people who want to learn from it.

I appreciate your concern and I believe this is just a simple case of miscommunication.

Please let me know whether or not the formatted contributions section of this post is up to the standards of the Utopian guidelines.

Hey Tensor. Thanks for the message.

No, there was no connection in your response to my message. We have recently begun changing the structure of Utopian and I have been given the role of Community Manager of the video tutorial category. One of my roles is to make sure that all contributors (especially the high volume contributors like yourself) are up to speed on all the guidelines and take feedback from the community back to Utopian to improve the system. So I have been giving unsolicited insight into guidelines whenever I can.

With you as a productive creator of content, I want to make sure I provide you with any help you may need to continue the work. The last thing I want to ever see if any contributor to do extensive work on a submission in the spirit of the Utopian guidelines and end up missing something that keeps a submission from being accepted. That would be very sad.

I can tell that you spend a great deal of time on these submissions. You asked for me to let you know if the format of your contribution was up the standards of Utopian. Absolutely. I sometimes point new contributors to your posts as a benchmark. Keep up the great work.

Utopian is very new and we may from time to time make some suggestions to try and improve things. If you have any suggestions I would love to hear.

Cheers,
buckydurddle

I am sorry, if it seemed like I was getting defensive. Some of my contributions in the past have been rejected and this was mostly due to misinformation (both in part due to my own misconceptions and the rapid growth of the platform). As a result of those experiences, I make sure to keep myself up to date on the rules by skimming through them at least one to two times a week to make sure that my contributions are acceptable.

I do really appreciate you going out of your way to give me advice; again I am sorry it it didn't seem like it. Thank for for the complements as well; I am glad that my contributions are being used to help other people contribute to the platform.

If there is anything else I can do or you think I should do, please feel free to let me know.

Regards,
Tensor

It's my pleasure. Glad to be of help.
Bucky

Hey @buckydurddle, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Congratulations @tensor! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Do not miss the last announcement from @steemitboard!

Hey @tensor I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64118.79
ETH 3390.14
USDT 1.00
SBD 2.51