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
- IDEA intellij or Visual Studio Code with the Dart/Flutter Plugins
- The Dart SDK and the Flutter SDK
- A fair understanding of Mobile development and Imperative or Object Oriented Programming
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:
- Dart Flutter Cross Platform Chat Application Tutorial
- Building a Temperature Conversion Application using Dart's Flutter Framework
Calculator Application
- Building a Calculator Layout using Dart's Flutter Framework
- Finishing our Calculator Application with Dart's Flutter Framework
Movie Searcher Application
Curriculum
- Building a Multi-Page Application with Dart's Flutter Mobile Framework
- Making Http requests and Using Json in Dart's Flutter Framework
- Building Dynamic Lists with Streams in Dart's Flutter Framework
- Using GridView, Tabs, and Steppers in Dart's Flutter Framework
- Using Global Keys to get State and Validate Input in Dart's Flutter Framework
- The Basics of Animation with Dart's Flutter Framework
- Advanced Physics Based Animations in Dart's Flutter Framework
- Building a Drag and Drop Application with Dart's Flutter Framework
- Building a Hero Animation and an Application Drawer in Dart's Flutter Framework
- Using Inherited Widgets and Gesture Detectors in Dart's Flutter Framework
- Using Gradients, Fractional Offsets, Page Views and Other Widgets in Dart's Flutter Framework
- Making use of Shared Preferences, Flex Widgets and Dismissibles with Dart's Flutter framework
- Using the Different Style Widgets and Properties in Dart's Flutter Framework
- Composing Animations and Chaining Animations in Dart's Flutter Framework
- Building a Countdown Timer with a Custom Painter and Animations in Dart's Flutter Framework
- Reading and Writing Data and Files with Path Provider using Dart's Flutter Framework
- Exploring Webviews and the Url Launcher Plugin in Dart's Flutter Framework
- Adding a Real-time Database to a Flutter application with Firebase
- Building a List in Redux with Dart's Flutter Framework
- Managing State with the Scoped Model Pattern in Dart's Flutter Framework
Posted on Utopian.io - Rewarding Open Source Contributors