fabiochiu/medium-articles huggingface dataset:
Flutter — My First Application. Basic Variables in dart Variables store…
By: Chandan Sharma
Tags: App Development, Flutter, Dart, Apps, Programming

Basic Variables in dart

Variables store references. Variable ‘x’ inferred to be String but you can change by specifying it.

A Dart string is a sequence of UTF-16 code units. You can use either single or double quotes to create a string

List: it is mutable (You can change the value of the list)

Lists use zero-based indexing, where 0 is the index of the first element and total_list_length -1 is the index of the last element.

List is also referred as Array’s in Dart language.

You can either give ‘var’ which dynamically consider itself as “List” depends on the values inside list or you can write as “List”

List can also be hard coded to specific data type, say “int”. It can be restricted only to int, if not it gives error.

Values of the list can be extracted depending on there index number.

Values of the list can be modified based on the index number.

List has a drawback that system assign the position number and anybody can change the position value, to overcome we have “Map” variable where you can assign position (key) and value.

Create a basic flutter app

Open cmd and create a folder inside your working directory and run flutter create <folder_name> which will load all libraries into the directory.

Import that folder into VS Code IDE

import ‘package:flutter/material.dart’;

void main() {

runApp(MaterialApp(

home: Text(“Hello Flutter”),

));

}

runApp will run the code as application on your phone.

MaterialApp gives material or set of code to design your widgets.

Run the sample code Without Debugging mode and wait for 1–2 min to execute.

The Text will be printed on the screen of your virtual phone.
Select and Upload images to Firebase Storage Flutter
By: Mercy Jemosop
Tags: Cloud Storage, Flutter, Firebase, Dart, Technology

Introduction

Cloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.

Firebase storage dependency. Add the dependency to your pubspec.yaml file. Check the latest version here.

Introduction

Cloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.

Firebase storage dependency. Add the dependency to your pubspec.yaml file. Check the latest version here.

Introduction

Cloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.

Firebase storage dependency. Add the dependency to your pubspec.yaml file. Check the latest version here.

Introduction

Cloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.

Firebase storage dependency. Add the dependency to your pubspec.yaml file. Check the latest version here.

dependencies:

flutter:

sdk: flutter

firebase_core: "^1.5.0"

firebase_storage: "^10.0.2"

Before we start using Storage we must first ensure we have initialized FlutterFire. This is usually done before any Firebase service is used. This step is asynchronous meaning flutterfire usage is prevented until initialization is complete.

await Firebase.initializeApp();

The initializeApp() method is asynchronous and returns a future. Update your main flutter function.

N.B You can change the rules on your storage to allow a user who is not signed in to upload files.

Now let’s create a new dart file to upload our files to storage

Step 1: import cloud storage package to our project.

import 'package:firebase_storage/firebase_storage.dart' as firebase_storage;

Step 2:Create a storage instance by calling the instance getter on Firebase Storage.

firebase_storage.FirebaseStorage storage =

firebase_storage.FirebaseStorage.instance;

Step 3: To select image from gallery or camera, add path and image picker dependency to your application.

path: ^1.8.0

image_picker: ^0.8.4

reference:https://fabcoding.com/2020/06/08/adding-an-image-picker-in-a-flutter-app-pick-images-using-camera-and-gallery-photos/

Happy Coding!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Select and Upload Files to Firebase Storage
By: Mercy Jemosop
Tags: Flutter, Firebase Storage, Firebase, Cloud Firestore, Dart

Introduction

Cloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.

Firebase storage dependency. Add the dependency to your pubspec.yaml file. Check the latest version here.

dependencies:

flutter:

sdk: flutter

firebase_core: "^1.5.0"

firebase_storage: "^10.0.2"

Before we start using Storage we must first ensure we have initialized FlutterFire. This is usually done before any Firebase service is used. This step is asynchronous meaning flutterfire usage is prevented until initialization is complete.

await Firebase.initializeApp();

The initializeApp() method is asynchronous and returns a future. Update your main flutter function

N.B You can change the rules on your storage to allow a user who is not signed in to upload files.

Now let’s create a new dart file to upload our files to storage

Step 1: import cloud storage package to our project.

import 'package:firebase_storage/firebase_storage.dart' as firebase_storage;

Step 2:Create a storage instance by calling the instance getter on Firebase Storage.

firebase_storage.FirebaseStorage storage =

firebase_storage.FirebaseStorage.instance;

Step 3: Select file from local storage. Add the file_picker and path dependency to your pubspec.yaml file.

To select file from local storage, Add the file_picker and path dependency to your pubspec.yaml file.

file_picker: ^4.0.1

path: ^1.8.0

Upload the selected image to cloud storage

Happy coding!!!!!!!!!!!!!!!!!!!!!!!!!!
Adding a Scrollbar to a scrollable widget (Flutter Tutorials)
By: Dev Bros
Tags: App Development, Scroll, UI, Flutter, Dart

Want a simple way to add a scrollbar to any scrollable widget? ScrollBar makes that very easy to implement!

Watch the tutorial here!

For this tutorial we are going to start off with a ListView (please keep in mind you can use any scrollable widget) like this:

Now all you have to do is wrap the ListView in a ScrollBar widget and this will add a scroll bar to your lists:

That was pretty easy! However this basic implementation only gives us a scrollbar that is visible while scrolling. If we want it to be always visible then we pass the value true to the isAlwaysShown argument:

You will notice that just passing this argument will cause an error and that is because we are missing a ScrollController. Adding a ScrollController consists of a few steps:

- Creating a ScrollController variable

- Instantiating the controller in our initState method

- Disposing of the controller in our dispose method

- Linking the controller to the ScrollBar and the ListView

Here in the full code implementation you can see these implemented:

Great job! You are now a certified pro in using ScrollBars. If you like us enough go check out some of our other content!
Handling Flutter Images like a Pro
By: Maruf Hassan
Tags: Tips And Tricks, Flutter, Dart, Images, Flutter App Development

When building a production-ready app, it is a good practice to keep all the Image assets in a single dart file. This makes debugging a lot easier and faster.

This is how people normally use Image widgets and Asset location in general.

Disadvantages of using this way -

IDE cannot detect String literals so any mistake goes unchecked. Debugging becomes difficult while you have to scavenge through different files to find the Asset location. Bugfixes require multiple commits in different files becoming more prone to merge conflicts.

To fix this we create a class that holds all the Images that our app will contain.

Create a dart file called images.dart in the constants folder.

The file will contain a class with a private constructor and Images used in our app.

class Images {

Images._(); static const String logoLight = 'assets/images/logo/light_mode_logo.png';

}

Images is the class name.

Images._(); is a private constructor which prevents the class from being instantiated.

static means a member is available on the class itself instead of on instances of the class.

const makes the variable immutable.

logoLight is the Image asset name.

‘assets/images/logo/light_mode_logo.png’ is the asset location.

Now that we understand what everything does, we will apply it to our code.

Replace the floating Asset location with Images.logoLight

Advantages of using this way -

Any error is caught by the IDE and is easy to fix. Debugging becomes a breeze since all the Images are in one file and fixing any spelling mistakes or changing any Image variable is very easy. Bugfixes require a single commit as all the Images are available in a single file, thus reducing the chances of merge conflicts.

I hope you liked the article. I plan on bringing more short articles like these to teach tips and tricks used in Production Level Flutter Development!

You can read about Handling Flutter Strings like a Pro in Part #2 of the series.

You can follow me on Twitter, Github, or Youtube to stay updated with all my new articles and videos.
Spacer and Widget. Welcome to the Widget Challenge
By: Yubaraj Poudel
Tags: Flutter Ui, Flutter Widget, Flutter, Dart, Web Development

Welcome to the Widget Challenge

Spacer manages the empty space between the widgets with flex container. Evenly with the Row and Column MainAxis alignment we can manage the space as well as shown in example.

//Alignment example

class RowColumnAlignment extends StatelessWidget {

List colors = [Colors.teal, Colors.red, Colors.blue]; _sampleWidget() => List<Widget>.generate(colors.length, (index) {

return new Container(

color: colors[index],

height: 50,

width: 50,

);

}); @override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text("Spacer and alignment"),

),

body: Container(

padding: EdgeInsets.all(8.0),

child: Column(

children: <Widget>[

SizedBox(

height: 16.0,

),

Text(

"Items are evenly distributed in the line with equal space around them (space around)"),

SizedBox(

height: 8.0,

),

Row(

mainAxisAlignment: MainAxisAlignment.spaceAround,

children: _sampleWidget()),

SizedBox(

height: 16.0,

),

Text(

"Items Spread across the screen however keeps equal space in between (space between)"),

SizedBox(

height: 8.0,

),

Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: _sampleWidget()),

SizedBox(

height: 16.0,

),

Text(

"items are distributed so that the spacing between any two adjacent alignment subjects, before the first alignment subject, and after the last alignment subject is the same (Space evenly)"),

SizedBox(

height: 8.0,

),

Row(

mainAxisAlignment: MainAxisAlignment.spaceEvenly,

children: _sampleWidget()),

],

)));

}

}

Output

{width: 200px;}

Spacer

Spacer in the flutter is as like the weight properties in the xml of java application. Spacer takes the flex in the constructor which defines the space. By default the value of flex is 1.

Sample

//Spacer example

class AlignmentWithSpacer extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

backgroundColor: Colors.white,

appBar: AppBar(

title: Text("Alligment with Spacer"),

),

body: Container(

padding: EdgeInsets.only(top: 16.0),

child: Row(children: [

Container(

color: Colors.red,

height: 50,

width: 50,

),

Spacer(), // default flex is 1

Container(

color: Colors.red,

height: 50,

width: 50,

),

Spacer(

flex: 2,

), // flex is 2

Container(

color: Colors.red,

height: 50,

width: 50,

)

])));

}

}

Output

Thanks for reading. We welcome the contributors who feels honor in helping other developers. Lets make better team together. For contribution please check https://github.com/flutterchallenge/widgetchallenge
Flutter: Database Migrations with sqflite_migrations
By: Leandro Doldán
Tags: Database, App Development, Migration, Flutter, Dart

Photo by Nicole Harrington on Unsplash

Have you ever felt so passionate about something that you spent days thinking about it non stop? That is the way I felt about my new mobile application idea. I started designing the screens, researching about Flutter components, and even codding the home page. But when I decided to add a database to the app I was really disappointed: there was no way to implement migrations on it!

Using migrations provide you with control of your database, letting you know in what state it is, and how to upgrade it or downgrade it. Even though you can go to production without them, I think that any application will benefit in the long run of having them, as the only constant in software development is change.

TL;DR: sqflite_migrations

Long story short, I created a very small library to implement migrations in Dart. You can use them either in Flutter or any other Dart framework as long as you are using SQFlite as your database connection. You can check the GitHub repository if you would like to check it out, make suggestions or collaborate!

How to use it

In your Dart project add the dependency:

dependencies:

...

sqflite_migrations: ^0.1.0

2. Create a new instance of the Migration class you imported from the package, specifying the migration’s name, an up method, and a down method.

Example:



Migration createUsersTable = new Migration(

‘create-users-table’,

() => '''

CREATE TABLE users(

id INT PRIMARY KEY,

name TEXT NOT NULL

);

''',

() => 'DROP TABLE users;',

);

3. Create a list of migrations. There you will add every migration you create during the life of your application, and you will only update them or delete them under very rare circumstances.

List<Migration> migrations = [

createUsersTable

];

4. Open the database with SQFlite, calling the runMigrations and the undoMigrations methods either in or as, the onUpgrade and the onDowngrade parameters.

Example:

Database db = await openDatabase(path,

version: _databaseVersion,

onCreate: _onCreate,

onUpgrade: runMigrations,

onDowngrade: undoMigrations);

I will love to hear about your experience adding migrations to your projects nad I encourage you to tell me about them either in GitHub or my email account! 😄
Build Hero Animation with Flutter
By: Vishwakarma Raj
Tags: Flutter Ui, Flutter Widget, Dart, Programming, Flutterio

Flutter is Google’s portable UI toolkit for building beautiful, natively-compiled applications for mobile, web, and desktop from a single codebase.

And now its time for you to have your Android app…. Deploy by you :)

Well.. yes you can learn to Code with Flutter…. Its all about Dart !!

Lets begin with a simple Code of making an Simple Animation for Image

Which on click Its popup a large image for the user to view the Image….

As you have been seeing on #Whatsapp #Instagram #Facebook and bla..bla..

Time to Code …well if you are new to #Flutter /#Dart you can learn the basics for here Lin to flutter Installation and other starting Guides…

Hope You have earned prior knowledge on flutter now time to learn #Hero Animation in simple process…

Which looks like this in the below Image….

This is what we will be making it….

Its quite easy to build such Animation…

Well Flutter Provides Built In such Functionality Just CODE it……

Let’s Start Coding then……..

No need to import Packages …. Quite Easy na !! hmhmhh……

Create and Stateful underlying a Stateless widget using (stqa) on VS CODE….(chitcode :P enjoy…)

You can have AppBar of your choice and so..body with Container and other designs that you want to implement…

Well you can place the image Directly as using Image()with GestureDetector(child:) under a Column(widgets[])/Center(child:)

I have used a Circle Avatar and inside background image…..

And yup !!! called a context widget on tap the Circle Avatar Image….

Still !! Hope you are enjoy Coding…. Let’s make the calling Function…

That what i need to show on tap …

I Hope now you are eager to get the #Source Code and here it is …………Enjoy Fluttering Community…

You can find the #SOURCE_CODE here …..

Just give a kudos to my repo if it help to build a Hero Animation in Flutter for you….

I know you were waiting for the source code so just enjoy coding…..

Enjoy #Fluttering…..
Integration and Unit testing in Flutter
By: Sagar Suri
Tags: iOS, Testing, Android, Flutter, Dart

Testing BLoC and Repository in Flutter

Integration and Unit testing in Flutter

Hi Folks! This is the last article for my series “Architect your Flutter project using BLoC pattern”. In this article, you will be learning another most important and critical part of software development i.e “Testing”. You will learn both Integration and Unit testing. This will help you deliver software that meets expectations and prevents unexpected results. So without further delay let’s write some test cases. 😄

Content

Creating the test directory Unit testing the Network Layer 💻 Integration testing the BLoC Running the test cases 🏃

Prerequisite

As this article is part of a series. I expect you to go through the previous parts of the series(links below). This will help you understand the whole architecture of MyMovies app and what were changes made in different parts of the series.

Other parts of the series

Part 1

Part 2

Part 3

Goal

Have you ever launched an app without testing? I hope your answer is “NO”. You don’t want your customers to have unexpected crashes or a buggy app. There is a beautiful quote regarding testing “If you don’t like testing your product, most likely your customers won’t like to test it either”.

Software testing is the most crucial part of any software development lifecycle. This will help you find bugs and errors that were made during the development phase. Ultimately this methodology will help you ship quality products to your customers. Today you will be testing the features of MyMovies app which was built in the previous parts of the series.

Unit and Integration test

A unit test is a test written by the programmer to verify that a relatively small piece of code is doing what it is intended to do. They are narrow in scope, they should be easy to write and execute.

Part of being a unit test is the implication that things outside the code under test are mocked or stubbed out. Unit tests shouldn’t have dependencies on outside systems.

An integration test is done to demonstrate that different pieces of the system work together. Integration tests can cover whole applications, and they require much more effort to put together. They usually require resources like database instances and hardware to be allocated for them. The integration tests do a more convincing job of demonstrating the system works (especially to non-programmers) than a set of unit tests can, at least to the extent the integration test environment resembles production.

Note: source StackOverflow

The above explanation is more than enough to understand the difference between unit and integration tests. This will help you understand which part of the code can be unit tested or you need to write integration tests.
Adding text selection action in Flutter for android.
By: Karthikeyan S
Tags: Flutter Plugin, Flutter Widget, Flutter, Dart, Flutter App Development

Have you ever wanted to give your user a shortcut, for opening the selected text in your flutter app from anywhere in the android environment?

Like this:

If yes, then you got yourself to the right place. In this article, I’m going to talk about how this can be implemented in flutter with the help of a pub plugin action_process_text, I wrote.

Let’s get started.

First, let’s create our flutter project.

flutter create action_process_text_example

Now, in the pubspec.yaml file, add the package

dependencies:

action_process_text: <latest version>

Run pub get and get packages.

Now add the following code to AndroidManifest.xml file in the android\app\src\main\ folder just after the main activity .

The android:label here is the String that will be displayed on selecting the text. So, change that to something relevant to what your app does.

Now that we have completed all the setup, let’s take a look at the usage.

Import the package.

import 'package:action_process_text/action_process_text.dart';

2. Write an async function for starting up the plugin in the Constructor of the StatefulWidget , which will assign the selected text to a variable with the help of await .

This package currently works only in a StatefulWidget as setState() has to be called.

The ActionProcessText.getInputText is used to get the selected text when the action is performed, otherwise return a blank space ‘’ . It returns a future, so await should be used in a variable declaration.

Then, setState() is performed to rebuild the page, as it would have already started building, without waiting for the inputText to get the future.

The inputText can also be re-used for other purposes when the action is not performed, and InputTextController can also be used instead.

The output is

Yahoo! We have done it.
Monetize your Flutter App using Ads
By: Dulanka Karunasena
Tags: Admob, Flutter, Firebase, Dart, Monetize

Photo by Pepi Stojanovski on Unsplash

Were you lost in the internet, searching the best possible way to integrate Ads into your Flutter mobile app? Lucky You! You’ve found the best and easiest explanation to your issue. This article will explain how to integrate Google’s Admob with Flutter.

Step 1: You need an Admob account

Go to Admob. Sign up with your Google account. Go to Apps > Add App Select if your app is already published or not. If published, you can search your app in stores or you can create new one and click ‘Add’. An App Id will be generated for your app.

Sample App ID: ca-app-pub-3940256099942544~3347511713

7. Click ‘Add ad unit’ to create an ad unit.

8. Choose the ad format.

9. Give a name to your ad unit and select your preferences in advanced settings and click ‘Create ad unit’.

10. An ad unit ID will be generated for your ad unit.

Sample ad unit ID: ca-app-pub-3940256099942544/6300978111

Step 2: Add the dependency

Add firebase_admob package inside the pubspec.yaml file of your project.

Step 3: Change the AndroidManifest.xml file

Include the following meta data tag, with your App ID to your app’s AndroidManifest.xml file.

Step 4: Integrate Firebase

Go to Firebase Console. Click on ‘Add Project’. Give a name to your project and select your preferences and click ‘Create Project’. Inside your Firebase project, select the platform (ios, android, web). Firebase will guide you smoothly in the process of integration.

Integrating Firebase will give you access to variety of data such as sessions, user demographics, revenue, crash reports and a lot more related to your app.

Step 5: Configure Ads

Add the following import inside your dart file.

import 'package:firebase_admob/firebase_admob.dart';

Use the following code to define the properties of your Ad depending on the ad format: Banner Ad, Interstitial Ad. Don’t forget to add the code inside the State of your Stateful Widget.

Step 6: Initialize and load Ad

Change your initState() method as shown below, in order to initialize and load the ad.

Bingo! We are all set and good to go. Real ads take some time to show in your app. If the test ads are working, you can sit back and relax.😎

Read the Admob policies on placing ads inside your app.

Visit my Playstore developer page here. See you again in another awesome article. Until then, Happy Coding! 💻
Drawer in Flutter in 5 Simple Steps
By: Gagandeep Gambhir
Tags: Flutter Ui, Flutter Widget, Flutter, Dart, Drawer

As we know a Drawer is a very handy option to manage the navigation of our mobile app. In apps that use Material Design, there are two primary options for navigation: tabs and drawers. When there is insufficient space to support tabs, drawers provide a handy alternative. In this article, we’ll see how to add a Drawer in the Flutter app in 5 steps.

Step1: Create a Scaffold

Scaffold(

drawer: // Add a Drawer here in the next step.

);

Step2: Add a Drawer

Scaffold(

drawer: Drawer(

child: // Populate the Drawer in the next step.

)

);

Step3: Populate the Drawer with Items

Drawer(

// Add a ListView to the drawer. This ensures the user can scroll

// through the options in the drawer if there isn't enough vertical

// space to fit everything.

child: ListView(

// Important: Remove any padding from the ListView.

padding: EdgeInsets.zero,

children: <Widget>[

DrawerHeader(

child: Text('Drawer Header'),

decoration: BoxDecoration(

color: Colors.blue,

),

),

ListTile(

title: Text('Item 1'),

onTap: () {

// Update the state of the app.

// ...

},

),

ListTile(

title: Text('Item 2'),

onTap: () {

// Update the state of the app.

// ...

},

),

],

),

);

Step4: Close the Drawer Programmatically

ListTile(

title: Text('Item 1'),

onTap: () {

// Update the state of the app.

// ...

// Then close the drawer.

Navigator.pop(context);

},

)

Step5: Open Drawer Programmatically

Declare a GlobalKey property for ScaffoldState in your stateful class.

final scaffoldKey = GlobalKey<ScaffoldState>();

Set the key property of Scaffold widget

key: scaffoldKey

Now open Drawer programmatically anywhere

onPress: () {

scaffoldKey.currentState.openDrawer();

},

Wow!! You did it. Happy Coding :)
How to avoid render wrapper for ng-content when it is not passed in Angular
By: Stepan Mikhaylyuk
Tags: Dartlang, Dart Angular, Dart, Angular, Angular2

Imagine that you have component that receives ng-content, wrapes it with container. Most popular task is to avoid rendering wrapper.

Solution 1

The simplest solution, which you can use is css:empty.

But this solution has many restrictions:

1) Only one wrapper supports

2) Wrapper’s DOM node just hidden, but rendered.

Solution 2

Let’s look to solution from angular components community using form-field code as example

The main idea of this solution is getting content children by @ContentChildren decorator and check exists it or not.

Look at @ContentChildren docs.

As you see, selector — The directive type or the name used for querying.

That means that we should to use directive to mark passed ng-content and to get access to it by @ContentChildren. And this is reason why angular components needs MatSuffix directive with empty body.

In the end of this solution, to make it working, you should add MatSuffix to your App where you use form-field.

But, MatSuffix looks like service directive, and theoretically, you can have many directives like it — you should to provide @NgModule for your consumer, like it implemented in angular form-field

See dart angular example.

Thank you!
Test-Driven Development with Flutter
By: Arnela Jasarevic
Tags: Testing, Flutter, Test Driven Development, Dart, Programming

Find out how to build a Flutter App with a Test-Driven Development approach. Get used to TDD with the Red-Green-Refactor rhythm, and never be afraid to make changes to your code.

“If you want your systems to be flexible, write tests. If you want your systems to be reusable, write tests. If you want your systems to be maintainable, write tests.” — Uncle Bob Martin

TEST-DRIVEN DEVELOPMENT

TDD is the process of creating software by writing tests in advance to prove the implementation fulfills the requirements. For most developers, it’s not something that comes naturally and the hardest part is to get used to it. But the good news is that the process of TDD is rhythmic, and because of that, I will try to show you by example how easy it is when you feel the rhythm. Basically, through all your work you need to repeat 3 steps/colors:

Write a failing test (Red phase) Make the test pass — Write just enough code to pass the test (Green phase) Improve the code — Clean up the mess (Refactoring phase)

FLUTTER AUTOMATED TESTS

Flutter has 3 categories of tests:

A widget test (tests a single widget) A unit test (tests a single function, method, or class) An integration test (tests a complete app or a large part of an app)

In this article, I will present widget tests, and how you can be sure that everything is shown to the user as you wanted. You can check the type of widgets, texts, colors, paddings, tap detections, etc.

Unit and integration tests will be included in the next article, so stay tuned!
Flutter and the mysterious -1073741819 error
By: Daniel Varga
Tags: Flutter, Dart

Ooops! That’s not good. Today, Flutter welcomed me with this message when I tried to run some tests:

Shell subprocess crashed with unexpected exit code -1073741819 after tests finished.

Test: C:\Users\Dev\Documents\Projects\awesome_app\test\some_test.dart

Shell: C:\Users\Dev\Documents\3rdParty\flutter\bin\cache\artifacts\engine\windows-x64\flutter_tester.exe

TL;DR

It happens because there is some weird memory addressing issue in the VM. Due to this access violation, the exit code of Flutter’s shell is set to that nice -1073741819 , 0xC0000005 in hex.This also affects Dart VM.

Affected Dart VMs: 2.3.0-dev.0.5, 2.3.1

Flutter: 1.5.4-hotfix.2

Platform: Win 10

Cause

This issue came up when I used generics together and typedef -s.

Running dartanalyzer on this piece of code only gave me a couple of lints, nothing to signify that I’ve screwed up big-time.

Workaround

Modifying the typedef will get rid of this crash. There are 2 options:

Seems like an innocent mistake, yet the VM punished me quite severely. Narrowing down what went wrong took a few hours. If this helped you, please drop a clap or a comment — your support is much appreciated!

edit: tracking issue on GitHub .

edit #2: issue has since been closed, seems like fix has landed
The road to Flutter cross-platform
By: Kevin Segaud
Tags: Desktop, Mobile, Flutter, Dart, Web Development

At Flutter live in December 2018 the Flutter team used a desktop app for their slide, they also give us a sneak peak of what has become Flutter web.

At google IO 2019 Flutter Web was open to everyone in a technical preview.

Today we will speak about Flutter application that work on Desktop, Mobile and Web with a single code base. To illustrate that we will use the well known counter example and add support for persistence of the counter for each supported platform.

The final code is in this repository all_platform_example

We need some sort of ‘plugins’ that work across all platform, for this example we will use 2 plugins that are located in the rc_cross repository.

The first plugin is rc_cross_platform who give us the platform we are running on !

The second plugin is rc_cross_preferences who allow use to save small data by using the best solution for the platform we are running on !

So if we are on mobile rc_cross_preferences will use the shared_preferences package, if we are on the web it will use the local storage, and on desktop it will write your key/value in a file.

Some screenshot of the application :

android :

linux:

This seems really cool but how it work ?

We will take the rc_cross_platform as an example.

If you look at the source code in lib/src you will see 4 files :

Let’s open platform_base.dart in this we define what we need across all platform it’s the base class for platform. We also have some code that are the same for each supported platform.

In platform_io.dart and platform_web.dart we have custom code for io (desktop / mobile) and web.

In platform_io.dart we use the Platform class from dart:io to back our value.

In platform_web.dart we set the web value of the PlatformBase to true (other are set to false by default).

Then we need a single file to import so it’s easy to use for the end user that file is platform.dart. We use conditional import to import the good file depending on where we are running. Here by default we import platform_io.dart but if we are in a js library, which happen when you compile your application with dart2js/ddc, it will replace that by platform_web.dart

We use the same technique in rc_cross_preferences the only change is that we use rc_cross_platform on the io side to choose between shared_preference/custom key/value file.

Manage State

We use Mobx as stated in the readme. It allow us to have a reactive way to be notified when the counter change. We have an extra Widget that load/save the counter. The rest is almost the same counter app from flutter create.

Sort of conclusion

WARNING: This is highly experimental and is subject to change drastically, as Flutter support more thing like Platform Channel for Desktop and Web.

It will be a really exciting time when all this will really come together.

There will be awesome opportunity to contributes to plugins to add support for these new platform.
Quick Tip: Firestore multiple operations in Flutter
By: Md Sadab Wasim
Tags: Database, Flutter, Android, Firebase, Dart

Advance firestore using batch

First of all what firebase documentation says about batch

Cloud Firestore supports atomic operations for reading and writing data. In a set of atomic operations, either all of the operations succeed, or none of them are applied. There are two types of atomic operations in Cloud Firestore:

Transactions : a transaction is a set of read and write operations on one or more documents.

: a transaction is a set of read and write operations on one or more documents. Batched Writes: a batched write is a set of write operations on one or more documents.

We can use two things to perform multiple operations, and in this article, we’ll cover batch.

Batched writes If you do not need to read any documents in your operation set (if you need to read document use transaction instead), you can execute multiple write operations as a single batch that contains any combination of set() , update() , or delete() operations. A batch of writes completes atomically and can write to multiple documents.

Write a document

var db= Firestore.instance(); //Create a batch

var batch = db.batch(); //And use this batch to write a document. batch.setData( //Give the ref of document. db.collection(’users’).document(’id’), //And the data to add in it. {'status': 'Approved'} );

Update a document

//Use the batch to update a document batch.updateData( //Give the ref of document. db.collection(’users’).document(’id’), //And the data to update. {'status': 'Rejected'});

Delete a document

//Use the batch to delete a document batch.delete( db.collection(’users’).document(’id’) );

And just commit the batch, when you want to perform the subscribed actions

batch.commit();

Photo by Vasily Koloda on Unsplash

That’s it, folks.

If you like this tiny little article, just clap for it 👏 👏 👏

Have a great day.
Flutter Beginners Tip — How To Change Application Launcher Icon
By: Pinkesh Darji
Tags: iOS App Development, Android App Development, Flutter, Mobile App Development, Dart

Create An App Icon

Before we see how to change the application icon we must have an app icon in the first place. So below are steps to create your own app icon.

Step 1: Click here and then click on ‘Launcher icon generator’

Step 2: Choose a foreground asset as any image or clipart or Text

Step 3: Select Color and Background color

Step 4 (Optional): Give some effect as Elevate, Cast shadow or Score. Play with it and choose the best suited to you.

Step 5: Name it and download it.

Let me share with you a screenshot of what I have created for this demo.

Let’s change the application launcher icon in a flutter.

Step 1: Put Icon in the project

Create an assets folder in the root of your project, create one more folder inside it and then put the app icon over there. Also, don’t forget to add the path of the image to pubspecs.yaml

Here is the screenshot for this

Step 2: Add the package

add the package from here to pubspecs.yaml

dependencies:

flutter:

sdk: flutter

flutter_launcher_icons: ^0.7.4

Step 3: Provide an app icon

Just add below code after adding a package

flutter_icons:

android: true

ios: true

image_path: "assets/images/ic_launcher.png"

Step 4: Fire the command to generate App icon in the terminal

flutter pub get

flutter pub run flutter_launcher_icons:main

Step 2,3,4 amalgamate should look like this

And you have successfully changed the App icons 👍

That’s it. Thanks for reading.

You can check out my other articles here
Explore Flutter 1.17 & Dart 2.8
By: Anmol Gupta
Tags: Mobile Apps, Flutter Widget, Mobile, Flutter, Dart

Dart 2.8

There are two changes made by the Dart team in the Dart 2.8 SDK:-

Improves performance in Pubget. Keeps our packages dependencies up-to-date.

flutter pub updated

Here is what is got when I run the pub outdated or fluter pub outdated command from my terminal.

C:\Users\anmol seth\AndroidStudioProjects\dialog_box>flutter pub outdated

Dependencies Current Upgradable Resolvable Latest

giffy_dialog *1.6.1 1.7.0 1.7.0 1.7.0



dev_dependencies: all up-to-date



transitive dependencies

collection *1.14.11 1.14.12 1.14.12 1.14.12

flare_dart *2.3.2 2.3.4 2.3.4 2.3.4

flare_flutter *1.8.3 2.0.3 2.0.3 2.0.3



transitive dev_dependencies

archive *2.0.11 2.0.13 2.0.13 2.0.13

args *1.5.2 1.6.0 1.6.0 1.6.0

async *2.4.0 2.4.1 2.4.1 2.4.1

boolean_selector *1.0.5 2.0.0 2.0.0 2.0.0

charcode *1.1.2 1.1.3 1.1.3 1.1.3

crypto *2.1.3 2.1.4 2.1.4 2.1.4

image *2.1.4 2.1.12 2.1.12 2.1.12

path *1.6.4 *1.6.4 *1.6.4 1.7.0

pedantic *1.8.0+1 - - 1.9.0

petitparser *2.4.0 *2.4.0 *2.4.0 3.0.2

quiver *2.0.5 2.1.3 2.1.3 2.1.3

source_span *1.5.5 1.7.0 1.7.0 1.7.0

test_api *0.2.11 0.2.15 0.2.15 0.2.15

xml *3.5.0 *3.6.1 *3.6.1 4.1.0



15 upgradable dependencies are locked (in pubspec.lock) to older versions.

To update these dependencies, use `pub upgrade`.

I got the suggestion regarding my current version and also the latest version available.

We can run pub upgrade to update these dependencies.
Using Hive instead of SharedPreferences for storing preferences
By: Michal Baran
Tags: Flutter, Mobile App Development, Dart, Hive, Cross Platform

Note that the units here are in milliseconds and even when I ran the benchmark for the write operation with 20 entries, time of Hive was ~40ms and time of SharedPreferences was ~160 ms.

Some people may say that the difference is too small for your users to notice, which for many apps is a fair thing to say, but I would argue that it’s better to use something that scales well and stay safe as we keep adding more preferences in our app.

Because when we add dozens of small optimisations like this, all these milliseconds will sum up and it will start being noticeable by our users.

Types supported

Hive not only supports all types that shared_preferences support - bool , int , double , String , List<String> but also DateTime , Uint8List and actually List and Map of any primitive types.

Hive not only supports all types that shared_preferences support - , , , , but also , and actually and of any primitive types. Encryption

If you would need to encrypt some values of your preferences Hive got you covered with AES-256 encryption built-in. You can read more about it here.

If you would need to encrypt some values of your preferences Hive got you covered with AES-256 encryption built-in. You can read more about it here. Verbosity

After all, Hive is a solid database library offering various features, so we might use it for data storage as well.

In which case we end up depending just on hive instead of hive and shared_preferences.

How

Firstly we need to set up Hive in our project. If you already have done this, then you can skip to step 4:

Add hive and hive_flutter in pubspec.yaml:

2. Add initFlutter() call in main.dart:

3. Optional step: Add Hive.close() in your main app class:

4. Preferences Implementation:

and that’s it. Now we can use Hive Preferences similarly as we used the shared_preferences plugin.

I like keeping my preferences keys private and exposing just concrete getters and setters, but alternatively, you could make getValue and setValue public and use it for everything.

Also, note that the Preferences instance doesn’t have to be a singleton nor does it have to be synchronised - we just want to make sure that box is open before we try accessing it. Alternatively, we could always be using openBox and then implementation would look something like this, but I think it’s slightly less convenient because then we would have all getters async as well.

Finally, here’s an example usage with a rewritten counter example:

Additional resources
Gloucester Township BOE reorganizes
By: Matthew Shinkle
Tags: Education, Students, New Jersey, Board Of Education, Schools

Gloucester Township BOE reorganizes

Three new members of the Gloucester Township Public Schools Board of Education were sworn in to their seats on Monday, Jan.7 Matthew Shinkle Jan 11, 2019·3 min read

The Gloucester Township Board of Education held its annual reorganization meeting Monday, Jan. 7, at the administration building to welcome three new board members elected this past November.

The ballot listed 15 registered candidates, according to the Camden County Board of Elections, with the three winners of the election being the only three candidates to receive a double-digit percentage of the vote.

Carolyn Grace received 14.13 percent, while Brian Reagan received 13.03 percent, and Anthony Marks received 10.99 percent of the more than 45,000 votes cast.

The three were sworn in together by Solicitor Dan Long at the reorganization meeting before taking their seats on the board and being welcomed by Superintendent John Bilodeau. All members of the board were present for the meeting.

At the meeting, MaryJo Dintino was elected as board president, and Mark Gallo was elected vice president, with the only “no” vote for both candidates coming from Jennifer O’Donnell.

Bilodeau made a few announcements to the board and to the public, saying the efforts of the district and additional organizations to raise money for the family for Michelle Barrett, a Chews Landing Elementary School teacher who died in a car accident in early December, have raised more than $7,000. At a previous meeting, Bilodeau had reported a lower figure.

Bilodeau also stated the board will be posting for an HR position in the near future, however it will have to discuss it a future personnel committee meeting before posting the job opening.

There were no comments from the public during public portion, however O’Donnell did make a comment as a board member near the end of the meeting.

“I will refuse to surrender my independent judgment to special interests or partisan political groups or to use the schools for political gain and for the use of friends,” O’Donnell said.

O’Donnell’s comment is the word-for-word statement made under letter F in the Code of Ethics for School Board Members, according to the state Department of Education.

Speaking as an individual and not a board representative later in a phone call with The Sun, O’Donnell said she takes school board ethics very seriously and wanted to simply state that out loud to remind the board of that specific line.

“I do feel that there is politics on our school board, and I’ve been saying that out loud for the two years that I’ve served over and over again,” O’Donnell said. “In my last year of the BOE, it’s been my goal to get politics off of the board. That’s my intent, that’s my goal.”

She said she was voted in to represent the public and to take everything into account and determine what is in the best interest of the children in the district for the taxpayers.
Maggie and Brady’s Wedding at Estate at Eagle Lake
By: Enchanted Celebrations
Tags: Wedding Photography, New Jersey, Wedding Photographer, Weddings

Congratulations to Maggie and Brady on their military-themed wedding! This lovely couple tied the knot to each other this past summer on July 18, 2020 at Estate at Eagle Lake in Chesterfield, NJ. Their Estate at Eagle Lake Wedding Photos turned out beautifully thanks to our talented wedding photographers.

First, the day began with the bride prep! Maggie got her makeup done with the help of her bridesmaids. Before they got into their beautiful tan dresses, the girls enjoyed some refreshing orange juice! Then, Maggie got into her gorgeous long white lace dress. Her father gave her the biggest hug when he saw her. Now, the first view began! Here, we saw Brady in his handsome navy blue military suit. Afterwards, the couple took portrait shots taking a stroll outside the venue right before the ceremony.

Next, the ceremony began! The outdoor wedding began with the groomsmen escorting Brady down the aisle. Afterwards, the bridesmaids made their way down the aisle with Maggie’s father escorting her to Brady. After the couple exchanged their vows, the officiant declared them husband and wife! The two shared a big kiss to conclude the ceremony. Thankfully, our photographers captured these wonderful moments in their Estate at Eagle Lake Wedding Photos!

Finally, the reception began! Their guests got together for group portrait shots to kick the celebration off! Then, the party began! Everyone danced the evening away and ate some delicious cake! Afterwards, Maggie and Brady got together for more portrait shots as newlyweds in the grassy field that their Estate at Eagle Lake Wedding Photos included. What a perfect way to end the day!

Congratulations to Maggie and Brady on their wedding! Above all, thank you for letting our photographers captured your amazing Estate at Eagle Lake Wedding Photos. We wish you both a lifetime of happiness together!

Check out their photos here:

https://www.enchantedcelebrations.com/eventcards/maggie-and-bradys-wedding-at-estate-at-eagle-lake/
Caitlin and Mike’s Wedding Videography at Private Residence
By: Enchanted Celebrations
Tags: New Jersey, Wedding Video, Wedding Videographers

Congratulations to Caitlin and Mike on their wedding! These two lovebirds tied the knot this past summer on August 1, 2020 at their private residence in Marlton, NJ. Thankfully, our Wedding Videographers in NJ made sure to capture every little moment of their big day.

First, the day began with a bride and groom prep! This vintage-themed wedding surely caught everyone’s attention! Caitlin rolled into the church’s parking lot in an elegant silver vintage car. Our Wedding Videographers in NJ caught a glimpse of her in the car looking absolutely beautiful, smiling, and holding a bouquet of flowers in her gorgeous white dress. Meanwhile, Mike got ready inside the church with the help of his groomsmen. He looked so handsome in his all black tuxedo with a white dress shirt, black bow tie, and a white corsage.

Next, the day continued with the first view! Caitlin and Mike’s friends and families gathered together to witness Mike look at Caitlin for the first time that day. The couple looked so happy! They shared a kiss and hugged each other as our team of Wedding Videographers in NJ captured the couple posing for detail shots inside the gazebo.

Finally, the ceremony began! Caitlin’s father walked his daughter up the altar to begin the ceremony. After the priest assisted the couple exchanged their vows, Mike put the wedding ring on Caitlin’ finger, officially pronouncing them husband and wife! The day concluded with the couple sharing a big kiss as they existed the church to start their lives together! Afterwards, everyone headed to their private Marlton residence for the reception!

Congratulations to Caitlin and Mike on their wedding. Above all, thank you for letting our Wedding Videographers in NJ capture your unforgettable day. We wish you both a lifetime of happiness together!

Check out their video here:

https://www.enchantedcelebrations.com/caitlin-and-mikes-wedding-videography-at-private-residence/