Flutter in Foldable Phones

Depicting and evaluating how Flutter is ready for Foldable Phones.

<iframe class="ql-video" frameborder="0" allowfullscreen="true" src="https://www.youtube.com/embed/fPBjbORMcU8?showinfo=0"></iframe>

<span class="ql-cursor"></span>

Learn More

Learn Flutter & Dart to Build iOS & Android Apps

Flutter & Dart - The Complete Flutter App Development Course

Dart and Flutter: The Complete Developer’s Guide

Let’s Develop a Mobile App in Flutter

Getting started with Flutter

Flutter Tutorial - Flight List UI Example In Flutter

Flutter Tutorial for Beginners - Build Android and iOS Apps with a Flutter Framework

Flutter Todos Tutorial with “flutter_bloc”

Flutter: Adding Bluetooth Functionality

Flutter: Adding Bluetooth Functionality

Introduction:


There is little documentation to no documentation on using Bluetooth in Flutter. In this article, I will help you by demonstrating some basic concepts needed to implement Bluetooth functionality in your app.

Firstly, plugin/dependency we will be using in this app to add Bluetooth is “flutter_bluetooth_serial”, this plugin is implemented from another parent plugin called “flutter_blue”. This is a very new plugin, the only plugin for bluetooth available as of now. It contains a few bugs but trust me, this will surely get your job done for most basic projects.

Note: Before we go any further, it is worth mentioning that this plugin will only work for Android

Implementation:

Add this dependency in your “pubspec.yaml” file :

<pre class="ql-syntax" spellcheck="false">dependencies: flutter_bluetooth_serial: ^0.0.4 </pre>

In the “main.dart” file the base code of the app will look like this:

<pre class="ql-syntax" spellcheck="false">import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: BluetoothApp(), // BluetoothApp() would be defined later
);
}
}
</pre>

Now, let’s create a StatefulWidget called “BluetoothApp”. In _BluetoothAppState, we need to define some variables and a Key. We also have to get an instance of FlutterBluetoothSerial in this class. This class will allow us to control and retrieve Bluetooth information.

<pre class="ql-syntax" spellcheck="false">class BluetoothApp extends StatefulWidget {
@override
_BluetoothAppState createState() => _BluetoothAppState();
}

class _BluetoothAppState extends State<BluetoothApp> {
// Initializing a global key, as it would help us in showing a SnackBar later
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
// Get the instance of the bluetooth
FlutterBluetoothSerial bluetooth = FlutterBluetoothSerial.instance;

// Define some variables, which will be required later
List<BluetoothDevice> _devicesList = [];
BluetoothDevice _device;
bool _connected = false;
bool _pressed = false;

@override
Widget build(BuildContext context) {
return Container(
// We have to work on the UI in this part
);
}
}
</pre>

Now, it’s time for implementing the critical portion of the app. We have to get the list of Paired Bluetooth devices and check whether the Bluetooth is connected. This is done asynchronously. We also have to create a list of devices, to be shown in the UI later.

These operations should be done in a “Future” method, which should be called from initState().

<pre class="ql-syntax" spellcheck="false">class _BluetoothAppState extends State<BluetoothApp> {
...

@override
void initState() {
super.initState();
bluetoothConnectionState();
}

// We are using async callback for using await
Future<void> bluetoothConnectionState() async {
List<BluetoothDevice> devices = [];

// To get the list of paired devices
try {
  devices = await bluetooth.getBondedDevices();
} on PlatformException {
  print("Error");
}

// For knowing when bluetooth is connected and when disconnected
bluetooth.onStateChanged().listen((state) {
  switch (state) {
    case FlutterBluetoothSerial.CONNECTED:
      setState(() {
        _connected = true;
        _pressed = false;
      });

      break;

    case FlutterBluetoothSerial.DISCONNECTED:
      setState(() {
        _connected = false;
        _pressed = false;
      });
      break;

    default:
      print(state);
      break;
  }
});

// It is an error to call [setState] unless [mounted] is true.
if (!mounted) {
  return;
}

// Store the [devices] list in the [_devicesList] for accessing
// the list outside this class
setState(() {
  _devicesList = devices;
});

}

@override
Widget build(BuildContext context) {
return Container(
// We have to work on the UI in this part
);
}
}
</pre>

Time to move on to the UI , the most beautiful part of Flutter coding. The code would be a little bit long but it would mostly contain easily readable code, if you are somewhat familiar with the Flutter Widgets. After completing this UI, we have to implement some methods.

<pre class="ql-syntax" spellcheck="false">...
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text("Flutter Bluetooth"),
backgroundColor: Colors.deepPurple,
),
body: Container(
// Defining a Column containing FOUR main Widgets wrapped with some padding:
// 1. Text
// 2. Row
// 3. Card
// 4. Text (wrapped with "Expanded" and "Padding")
child: Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
"PAIRED DEVICES",
style: TextStyle(fontSize: 24, color: Colors.blue),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
// Defining a Row containing THREE main Widgets:
// 1. Text
// 2. DropdownButton
// 3. RaisedButton
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Device:',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
DropdownButton(
// To be implemented : _getDeviceItems()
items: _getDeviceItems(),
onChanged: (value) => setState(() => _device = value),
value: _device,
),
RaisedButton(
onPressed:
// To be implemented : _disconnect and _connect
_pressed ? null : _connected ? _disconnect : _connect,
child: Text(_connected ? 'Disconnect' : 'Connect'),
),
],
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Card(
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(8.0),
// Defining a Row containing THREE main Widgets:
// 1. Text (wrapped with "Expanded")
// 2. FlatButton
// 3. FlatButton
child: Row(
children: <Widget>[
Expanded(
child: Text(
"DEVICE 1",
style: TextStyle(
fontSize: 20,
color: Colors.green,
),
),
),
FlatButton(
onPressed:
// To be implemented : _sendOnMessageToBluetooth()
_connected ? _sendOnMessageToBluetooth : null,
child: Text("ON"),
),
FlatButton(
onPressed:
// To be implemented : _sendOffMessageToBluetooth()
_connected ? _sendOffMessageToBluetooth : null,
child: Text("OFF"),
),
],
),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(20),
child: Center(
child: Text(
"NOTE: If you cannot find the device in the list, "
"please turn on bluetooth and pair the device by "
"going to the bluetooth settings",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.red),
),
),
),
)
],
),
),
),
);
}
</pre>

So, now it’s time for implementing the remaining methods. At first let us start with the _getDeviceItems() method.

<pre class="ql-syntax" spellcheck="false"> ...
// Create the List of devices to be shown in Dropdown Menu
List<DropdownMenuItem<BluetoothDevice>> _getDeviceItems() {
List<DropdownMenuItem<BluetoothDevice>> items = [];
if (_devicesList.isEmpty) {
items.add(DropdownMenuItem(
child: Text('NONE'),
));
} else {
_devicesList.forEach((device) {
items.add(DropdownMenuItem(
child: Text(device.name),
value: device,
));
});
}
return items;
}
</pre>

With the UI out of the way, we are left with four methods. For this example, we will be implementing the connect and disconnect methods. We’ll also implement a method to display a “SnackBar” to the user if there are no Bluetooth device is selected when the user tries to connect.

<pre class="ql-syntax" spellcheck="false">...
// Method to connect to bluetooth
void _connect() {
if (_device == null) {
show('No device selected');
} else {
bluetooth.isConnected.then((isConnected) {
if (!isConnected) {
bluetooth
.connect(_device)
.timeout(Duration(seconds: 10))
.catchError((error) {
setState(() => _pressed = false);
});
setState(() => _pressed = true);
}
});
}
}

// Method to disconnect bluetooth
void _disconnect() {
bluetooth.disconnect();
setState(() => _pressed = true);
}

// Method to show a Snackbar,
// taking message as the text
Future show(
String message, {
Duration duration: const Duration(seconds: 3),
}) async {
await new Future.delayed(new Duration(milliseconds: 100));
_scaffoldKey.currentState.showSnackBar(
new SnackBar(
content: new Text(
message,
),
duration: duration,
),
);
}
...
</pre>

At this point, we are almost finished. We are now left with two methods, one for sending a message to turn on Bluetooth and the other for sending a message to turn off Bluetooth.

<pre class="ql-syntax" spellcheck="false"> ...
// Method to send message,
// for turning the bletooth device on
void _sendOnMessageToBluetooth() {
bluetooth.isConnected.then((isConnected) {
if (isConnected) {
bluetooth.write("1");
show('Device Turned On');
}
});
}

// Method to send message,
// for turning the bletooth device off
void _sendOffMessageToBluetooth() {
bluetooth.isConnected.then((isConnected) {
if (isConnected) {
bluetooth.write("0");
show('Device Turned Off');
}
});
}
...
</pre>

That’s it! the Dart code required to make this work is now complete. That said, if we try running our app it will crash:

To fix this, we need to add the sdk to the AndroidManifest. Navigate to your project folder and follow these steps: android -> app -> src -> main -> AndroidManifest.xml

Add these two lines of code in your “AndroidManifest.xml” file :

<pre class="ql-syntax" spellcheck="false"><manifest ...
<!-- Add this line (inside manifest tag) -->
xmlns:tools="http://schemas.android.com/tools">

&lt;!-- and this line (outside manifest tag) --&gt;
&lt;uses-sdk tools:overrideLibrary="io.github.edufolly.flutterbluetoothserial"/&gt;
....

</manifest>
</pre>

Conclusion:

As I said at the beginning of this article, this plugin contains some bugs and is still under development.

Below are some screenshots showing various phases. If the user doesn’t have permission, the first thing the user will see is a prompt to grant the app location access. This is completely normal, just click “Allow” and everything should be fine.


Screenshots:

You are free to modify the code to add more functionality to the app.

The GitHub repo link for this project is here

If you like this project, please give “Stars” in my GitHub repo. Thank you for reading, if you enjoyed the article make sure to show me some love by hitting that clap button!

Happy coding…


Learn More

Getting started with Flutter

Flutter Tutorial - Flight List UI Example In Flutter

Let’s Develop a Mobile App in Flutter

Mastering styled text in Flutter

A Design Pattern for Flutter

Weather App with “flutter_bloc”

How to integrate your iOS Flutter App with Firebase on MacOS

An introduction to Dart and Flutter

Learn Flutter & Dart to Build iOS & Android Apps

Flutter & Dart - The Complete Flutter App Development Course

Dart and Flutter: The Complete Developer’s Guide

Flutter - Advanced Course

Originally published by Souvik Biswas at https://medium.com/flutter-community

Flutter - State Management using PROVIDER

Flutter - State Management using PROVIDER

So Let’s get started

Before looking into providers lets see whatsis ChangeNotifier this plugin uses ChangeNotifier to to listen and update any changes.

What is ChangeNotifier

Form docs

A class that can be extended or mixed in that provides a change notification API using [VoidCallback] for notifications.
[ChangeNotifier] is optimized for small numbers (one or two) of listeners. It is O(N) for adding and removing listeners and O(N²) for dispatching notifications (where N is the number of listeners)


Provider

Existing providers

provider exposes a few different kinds of "provider" for different types of objects.

Let's get started with our code

first things first let add plugin to pubspec.yaml

<pre class="ql-syntax" spellcheck="false">provider: ^2.0.1 http: ^0.12.0+2 </pre>

Let's Write our provider class first we name it AppState

<pre class="ql-syntax" spellcheck="false">import 'package:flutter/material.dart';

class AppState with ChangeNotifier {
AppState();

String _displayText = "";

void setDisplayText(String text) {
_displayText = text;
notifyListeners();
}

String get getDisplayText => _displayText;
}
</pre>


Our AppState is extended with ChangeNotifier which is used to notify its listeners when we call notifyListeners()

In the code, we declared two methods setDisplayText and getDisplayText which are used to read and write the value in our state

Now we move to our main.dart

<pre class="ql-syntax" spellcheck="false">import 'package:flutter/material.dart';
import 'package:flutter_demo_provider/app_state.dart';
import 'package:flutter_demo_provider/text_display.dart';
import 'package:flutter_demo_provider/text_edit.dart';
import 'package:provider/provider.dart';

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

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: ChangeNotifierProvider<AppState>(
builder: (_) => AppState(),
child: MyHomePage(),
));
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);

@override
_MyHomePageState createState() => _MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(
padding: const EdgeInsets.all(16.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
TextDisplay(),
TextEditWidget(),
],
),
),
),
);
}
}
</pre>


In the code, we can notice we have used ChangeNotifierProvider which is provided from out provider plugin

It accepts two parameters one is builder and the other is child

<pre class="ql-syntax" spellcheck="false">return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: ChangeNotifierProvider<AppState>(
builder: (
) => AppState(),
child: MyHomePage(),
));
}
</pre>

Inside the MyHomePage we have a Scaffold with Column which has two Widgets TextDisplay() and TextEditWidget()

<pre class="ql-syntax" spellcheck="false">TextDisplay(),
TextEditWidget(),
</pre>

Here is out TextDisplay() in text_display.dart

<pre class="ql-syntax" spellcheck="false">import 'package:flutter/material.dart';
import 'package:flutter_demo_provider/app_state.dart';
import 'package:provider/provider.dart';

class TextDisplay extends StatefulWidget {
@override
_TextDisplayState createState() => _TextDisplayState();
}

class _TextDisplayState extends State<TextDisplay> {
@override
Widget build(BuildContext context) {
final appState = Provider.of<AppState>(context);

return Container(
  padding: const EdgeInsets.all(16.0),
  child: Text(
    appState.getDisplayText,
    style: TextStyle(
      fontSize: 24.0,
    ),
  ),
);

}
}
</pre>


In the above code we see

<pre class="ql-syntax" spellcheck="false">Widget build(BuildContext context) {
final appState = Provider.of<AppState>(context);

return Container(
padding: const EdgeInsets.all(16.0),
child: Text(
appState.getDisplayText,
style: TextStyle(
fontSize: 24.0,
),
),
);
}
final appState = Provider.of<AppState>(context);
</pre>

This above line of code will get the provider for listening for any changes optionally we can also opt-out for listening by proving listen: false

<pre class="ql-syntax" spellcheck="false">final appState = Provider.of<AppState>(context, listen: false);
</pre>

Now in order to access text, we have a function in our provider called getDisplayText

<pre class="ql-syntax" spellcheck="false">appState.getDisplayText()
</pre>

Here is out TextEditWidget() in text_edit.dart

<pre class="ql-syntax" spellcheck="false">
import 'package:flutter/material.dart';
import 'package:flutter_demo_provider/app_state.dart';
import 'package:provider/provider.dart';

class TextEditWidget extends StatefulWidget {
@override
_TextEditWidgetState createState() => _TextEditWidgetState();
}

class _TextEditWidgetState extends State<TextEditWidget> {
TextEditingController _textEditingController = TextEditingController();

@override
Widget build(BuildContext context) {
final appState = Provider.of<AppState>(context);

return Container(
  child: TextField(
    controller: _textEditingController,
    decoration: InputDecoration(
      labelText: "Some Text",
      border: OutlineInputBorder(),
    ),
    onChanged: (changed) =&gt; appState.setDisplayText(changed),
    onSubmitted: (submitted) =&gt; appState.setDisplayText(submitted),
  ),
);

}
}
</pre>

In the above code, we get our appState inside the build function

<pre class="ql-syntax" spellcheck="false">final appState = Provider.of<AppState>(context);
</pre>

In order to manipulate the text in the state we call setDisplayText(text) function

<pre class="ql-syntax" spellcheck="false">TextField(
controller: _textEditingController,
decoration: InputDecoration(
labelText: "Some Text",
border: OutlineInputBorder(),
),
onChanged: (changed) => appState.setDisplayText(changed),
onSubmitted: (submitted) => appState.setDisplayText(submitted),
)
</pre>

we are updating the state whenever out text is changes

<pre class="ql-syntax" spellcheck="false">onChanged: (changed) => appState.setDisplayText(changed)
</pre>


Now we perform network operation

Now inside our app state, we have some additional functions and variables

<pre class="ql-syntax" spellcheck="false">String _dataUrl = "https://reqres.in/api/users?per_page=20";
String _jsonResonse = "";
bool _isFetching = false;

bool get isFetching => _isFetching;

Future<void> fetchData() async {
_isFetching = true;
notifyListeners();

var response = await http.get(_dataUrl);
if (response.statusCode == 200) {
_jsonResonse = response.body;
}

_isFetching = false;
notifyListeners();
}

String get getResponseText => _jsonResonse;

List<dynamic> getResponseJson() {
if (_jsonResonse.isNotEmpty) {
Map<String, dynamic> json = jsonDecode(_jsonResonse);
return json['data'];
}
return null;
}
</pre>

Here we have a few more functions fetchData, getResponseText and getResponseJson

fetchData will perform the network operation and update the variable with the response data (you can parse your JSON to custom model here and save it in a List)

getResponseText will return the plain text response

getResponseJson will convert the response text to a Map and returndata field inside it which is a list of Map

To see the final app_state.dart visit below link

Now inside out MyHomePage widget we add two more widgets to our column

<pre class="ql-syntax" spellcheck="false">RaisedButton(
onPressed: () => appState.fetchData(),
child: Text("Fetch Data from Network"),
),
ResponseDisplay(),
</pre>

So I am calling appState.fetchData() whenever I press the button now fetchData will take care of all the updating of the state on Github

Here is our ResponseDisplay Widget named response_display.dart

<pre class="ql-syntax" spellcheck="false">
import 'package:flutter/material.dart';
import 'package:flutter_demo_provider/app_state.dart';
import 'package:provider/provider.dart';

class ResponseDisplay extends StatefulWidget {
@override
_ResponseDisplayState createState() => _ResponseDisplayState();
}

class _ResponseDisplayState extends State<ResponseDisplay> {
@override
Widget build(BuildContext context) {
final appState = Provider.of<AppState>(context);

return Container(
  padding: const EdgeInsets.all(16.0),
  child: appState.isFetching
      ? CircularProgressIndicator()
      : appState.getResponseJson() != null
          ? ListView.builder(
              primary: false,
              shrinkWrap: true,
              itemCount: appState.getResponseJson().length,
              itemBuilder: (context, index) {
                return ListTile(
                  leading: CircleAvatar(
                    backgroundImage: NetworkImage(
                        appState.getResponseJson()[index]['avatar']),
                  ),
                  title: Text(
                    appState.getResponseJson()[index]["first_name"],
                  ),
                );
              },
            )
          : Text("Press Button above to fetch data"),
);

}
}
</pre>

Here in the above code we parse the JSON and build a list of data




To get the code it's here on GitHub


Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Learn More

Learn Flutter & Dart to Build iOS & Android Apps

Flutter & Dart - The Complete Flutter App Development Course

Dart and Flutter: The Complete Developer’s Guide

Flutter - Advanced Course

Flutter Tutorial for Beginners - Full Tutorial

Flutter Tutorial - Flight List UI Example In Flutter

Let’s Develop a Mobile App in Flutter

A Design Pattern for Flutter

An introduction to Dart and Flutter

Introduction to Flutter: Building iOS and Android Apps from a Single Codebase

Learn Flutter & Dart to Build iOS & Android Apps

10 Dart Tips That Every Beginner Should Learn

10 Dart Tips That Every Beginner Should Learn

Dart is a programming language that has been gaining traction in the last year or two, thanks to Flutter. Even though the language was released back in 2013, Google deciding to use Dart in Flutter has been a real game-changer for the language. In 2019 Dart made it to the Jetbrains survey of programming languages for the first time.

10 Dart Tips That Every Beginner Should Learn

Dart ranked 18 in the Jetbrains Survey

So if you’re new to the developer ecosystem, Dart is something that I would definitely suggest learning alongside JavaScript (wasn't it already obvious from the picture?) It’s sure to gain more popularity with the growth of flutter.

So let’s dive in and go through some of the most useful methods in Dart in three sections : lists, strings, and date-time.

Lists or Arrays

1. map()

Themap() method creates a new list that contains the results of running a callback on every element in the original list.

var cars = [ 'mercedes’,‘bmw’,‘audi’,'tesla'];
var mapCars = cars.map((car) => ‘My car is  $car’).toList();
print(mapCars);

The output of the above code would be:

[My car is mercedes, My car is bmw, My car is audi, My car is tesla]

2. sort()

sort() can be used to order the elements based on the provided sorting function. It works without a function too.

cars.sort();
print(cars);
or using method cascades
print(cars..sort());

The above snippets will print this:

[audi, bmw, mercedes, tesla]

We can always define our own comparison logic as well. Say we need to sort by comparing the price of each car, which will be obtained from a function getPrice(). We write our sort logic, as shown below, and it will sort the cars list based on their given price:

cars.sort((a, b) => getPrice(a).compareTo(getPrice(b)));

3. contains()

This is used to check if a given element is present in a list. contains()returns a boolean value.

print(cars.contains('bmw')); // output => true
print(cars.contains('toyota')); // output => false

4. reduce()

Thismethod also runs a callback for each element of an array. But reduce passes the result of each callback to the next iteration. This passed value is commonly known as an accumulator(value is accumulated through each iteration).

var numbers = [1, 3, 2, 5, 4];
var product = numbers.reduce((curr, next) => curr * next);
print(product);

The output of the above snippet will be 120.

Which is obtained from: 13 + 32 + 65 + 304.

Here accumulators after each iteration would be 3, 6, 30, and 120 respectively_._

String

5. startsWith() and endsWith()

As the name suggests, thestartsWith() method can be used to check whether a string starts with the given sequence of characters and theendsWith() method can be used to check if a string ends with the given sequence of characters. As you can see below, it’s case sensitive:

var name = ‘Medium is a great place to write articles’;
print(name.startsWith(‘Medium’)); // output => true
print(name.startsWith(‘medium’)); // output => false
print(name.endsWith(‘articles’)); // output => true
print(name.endsWith(‘medium’)); // output => false

6. padLeft() and padRight()

This method adds padding to the string using a given character or string, if the length of the string is less than the specified length:

var name = ‘I love Medium’;
print(name.padLeft(20, ‘xa’));
// output => xaxaxaxaxaxaxaI love Medium
print(name.padRight(20, ‘x’));
// output => I love Mediumxxxxxxx

7. splitMapJoin()

Basically, this does all three operations together. According to flutter.io it:

Splits the string, converts its parts, and combines them into a new string.

var newString = ‘I love medium I love medium’.splitMapJoin((new RegExp(r’medium’)),
 onMatch: (m) => ‘like ${m.group(0)}\n’,
 onNonMatch: (n) => ‘’);
 print(newString);

The output of the above snippet will be:

like medium
like medium

Date

8. isAfter() and isBefore()

Returns true if the given date occurs after the other.

var independenceDay = DateTime.utc(2019, 07, 4);
var halloween2019 = DateTime.utc(2019, 10, 31);
print(halloween2019.isAfter(independenceDay)); // output => true
print(halloween2019.isBefore(independenceDay)); // ouput => false

9. toLocal()

Converts DateTime value to the current time zone.

var date = DateTime.utc(2019, 10, 15);
print(DateTime.utc(2019, 10, 15)); 
// output => 2019–10–15 00:00:00.000Z
print(date.toLocal());
// output => 2019–10–15 05:30:00.000

10. weekday and month

These are properties and not methods. weekday can be used to check the day of a given date. It returns an integer 1–7 ( Monday to Friday).

var independenceDay = DateTime.utc(2019, 07, 4);
print(independenceDay.weekday); 
// output => 4
print(independenceDay.weekday == DateTime.sunday);  
// output => false

monthcan be used to check the month of a given date. It returns an integer 1–12 ( January to December).

var independenceDay = DateTime.utc(2019, 07, 4);
print(independenceDay.month == 5); 
// output => 7
print(independenceDay.month == DateTime.july);
// output => true

Thank you for reading!

5 Best Mobile App Development Frameworks You Should Know in 2020

5 Best Mobile App Development Frameworks You Should Know in 2020

The mobile app development frameworks not only offer a cheaper option to build mobile apps, but they also deliver native-like user experience, which is what a business or a company with strict budget needs.

Although, it is critical to choose the right mobile app development framework, as the choice of framework can make or break the success of your mobile app.

What is a Mobile App Development Framework?

A mobile app development framework is a library that is designed to help developers in building mobile apps. It basically provides a fundamental structure that not only supports mobile application development, but it also boosts the process while reducing the costs at the same time.

In this article, I have listed the 5 best mobile app development frameworks that we highly recommend to all of our clients.

5 Best Mobile App Development Frameworks in Detail

Choosing the right mobile app development framework depends on a number of factors.

That’s being said, let’s understand the best 5 mobile app frameworks individually that make the mobile app development simple.

1 — React Native

React Native was launched by Facebook in 2013, and since then it has become the prime choice of mobile app developers.

React Native is a Javascript-based, open-source cross-platform app development framework that allows developers to build high-performance mobile apps with shorter development cycles and faster deployment times.

The best part about React Native is that it’s a JSX-based (JavaScript-XML) framework, which means developers need not learn any complex programming languages such as Swift or Java in order to build mobile apps.

The framework takes care of converting the React Native code into native views before rendering so that grants a native-like experience for its end-users.

Advantages of React-Native:

  • Optimal Performance
  • Reusability
  • Proficiency
  • Lots of third-party plug-ins
  • Modular architecture

2 — Flutter

Flutter was launched by Google and is basically an open-source software development kit (SDK) for developing mobile apps. Unlike React Native apps or Hybrid Apps, Flutter is capable of fully compiling to native code.

This compilation allows mobile app developers to give not native-like but truly-native feel. Google made this possible through its graphics engine called Skia, which is a popular 2D graphics engine built by Google.

Flutter uses Dart as its primary programming language and it can construct cross-platform mobile apps for both iOS and Android that can run on any device.

In a nutshell, Flutter is considered to be the best mobile application development framework amongst all frameworks available in the market.

However, you should utilize Flutter only for a certain type of mobile app projects. And this is why you must consult with a mobile app development company if you’re not completely confident about the framework you’re planning to use.

Advantages of Flutter:

  • Flexible UI
  • Light-weight components
  • Lighting fast speed
  • Native performance

3 — Ionic

Ionic is free, open-source, and also one of the most widely used mobile app framework for building mobile apps.

Ionic basically enables mobile app developers to build native-based apps for various platforms with the combination of HTML, CSS3, and JavaScript.

It uses minimal DOM to maximize performance and better efficiency and also provides native APIs like Ionic Native and Cordova.

Apart from this, the element of HTML5 in Ionic also allows developers to build hybrid apps.

Advantages of Ionic:

  • Fast Execution
  • Near-Native Performance
  • Cordova Plugins
  • Easy to adopt

4 — Xamarin

Microsoft bought Xamarin from its founder in 2016 and they made it open-source ever since.

Xamarin is basically a cross-platform app development framework based on C# programming language that takes a slightly different approach than the rest of the mobile app frameworks.

For instance, Xamarin allows code sharing, which ultimately saves a lot of developers’ time in building mobile apps for multiple platforms.

In addition, Xamarin also comes with an excellent native UI, which allows businesses to build truly-native apps to give the best user experience to their customers.

Advantages of Xamarin:

  • Native UI
  • Easy API Integration
  • Shared Code Base
  • Huge Community
  • Less complex development environment

5 — Adobe PhoneGap

Adobe PhoneGap is another popular mobile app framework that uses HTML5, CSS3, and JavaScript to build mobile apps.

One of the main reasons why it’s in the list of best mobile app development frameworks is its best-in-class performance, which enables mobile app developers to build apps without facing any hardware restrictions.

Apart from this, PhoneGap also supports using inbuilt hardware features such as Storage, Phonebook, Accelerometer, Camera, GPS, etc.

In fact, unlike most hybrid mobile app frameworks, PhoneGap can build mobile apps for almost all major operating systems including Blackberry, Windows, Ubuntu, Firefox OS, Mac OS, and of course, Android & iOS.

Advantages of Adobe PhoneGap:

  • Supports most major OS
  • Based on HTML5, CSS3, JavaScript
  • Uniformity across platform
  • Robust support
  • Flexible with web technologies

Conclusion

Mobile app development frameworks are basically driving tools to build mobile apps. And the above-mentioned 5 frameworks have proved to be the best mobile app development frameworks in the market.

Best IDE and tools for Flutter development

Best IDE and tools for Flutter development

Things such as Hot Reload, a vast widget catalog, very good performance, and a solid community contribute to meeting that objective and makes Flutter a pretty good framework.

Imagine if you could make Flutter development faster, and see an instant boost in your workflow.

or even better:

What if there were best Flutter IDE and tools to choose from.

…and each of them could make your development faster and easier?

You’d probably be pumped to read about them.

Lucky for you, that’s exactly what I’m going to share with you in this post:

Best Flutter IDEs and tools can become an unparalleled ally when it comes to code completion and visual assistance for debugging and building a Flutter app.

These IDEs and tools are the best you can find for developing mobile applications. But to use these with Flutter, we will need to use a few plugins.


Flutter IDEs

For Flutter, it’s best to use Android Studio/IntelliJ or Visual Studio (VS) code with Mac/Windows as your operating systems.

These IDEs are the best you can find for developing mobile applications. But to use these with Flutter, we will need to use a few plugins.

We will need a plugin for the Dart compiler, another for code analysis, and another for the Flutter developer workflow (building, running, and debugging).

 


1. Android Studio

Android Studio or IntelliJ is the Recommend IDE by Flutter developers.

It provides you code completion, syntax highlighting, widget editing assists, run & debug support, and more.

There’s a browser-dev-tools style Inspector and more in the debug tools.

Download Android Studio

 

 2. Visual Studio Code

Visual Studio Code is also recommended by Flutter Developers, This  IDE built for developing and debugging web applications as well as Flutter apps. it has integrated Git control & terminal. It has a very large plugin system that probably rivals the Sublime quality and surpasses it for web language. It has all the necessary features and plugins to develop a full-fledged Flutter app with ease.

Download VsCode

 

Pub and Libraries

pub is the Dart package management system. There’s a website where can browse, search and get info about all the available packages for Dart and Flutter.

Dart Pub Packages


Gitter

If you run into any problems, you can ask for help in real time on the Flutter Gitter Channel. There you’ll find Flutter team members from Google as well as a supportive community of fans.


Frameworks

Standard

  • Bloc – Collection of packages that help implement the BLoC design pattern by Felix Angelov.
  • MobX – Supercharge the state-management in your apps with Transparent Functional Reactive Programming (TFRP). Port of MobX from the Js/React land.

Redux / ELM / Dependency Injection

  • Built redux – Automatic subscribing to your redux stores. Based on the built pattern by David Marne.
  • Redux.dart – Port of Redux to Dart with an ecosystem of middleware, Flutter integrations, and time traveling dev tools by John Ryan and Brian Egan.
  • Redux – Built to work with redux.dart, utilities that allow you to easily consume a Redux Store to build Widgets.
  • Dartea – Model View Update inspired by TEA from ELM by Shilyagov P.
  • Inject – Compile-time dependency injection by Google.
  • Flux – Implementation of the Flux framework by Google.
  • Fish – Alibaba Redux implementation.

 

Data

 

Game Engine


Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Learn More

Learn Flutter & Dart to Build iOS & Android Apps

Flutter & Dart - The Complete Flutter App Development Course

Dart and Flutter: The Complete Developer’s Guide

Flutter - Advanced Course

Flutter Tutorial for Beginners - Full Tutorial

Flutter Tutorial - Flight List UI Example In Flutter

Let’s Develop a Mobile App in Flutter

A Design Pattern for Flutter

An introduction to Dart and Flutter

Introduction to Flutter: Building iOS and Android Apps from a Single Codebase

Learn Flutter & Dart to Build iOS & Android Apps

Originally published on https://www.dunebook.com/