Flutter Interview Questions

Flutter Interview Questions:

Flutter Interview Questions
  1. What is Flutter?
  • Open-source UI toolkit.
  • Natively compiled applications for desktop, web, and mobile from a single codebase.
  • That is build using dart programming language.
  • Flutter 1.0 is officially announced on Dec 04, 2018.

2.When flutter is released and stable?

First alpha version was released on May 2017; and after 1.5 years, Flutter got its first stable 1.0 release on December 4th, 2018.

3. What is Dart and why does Flutter use it?

Dart is an object-oriented, garbage-collected programming language.

Dart was chosen as the language of Flutter for the following reason:

  • Dart is AOT (Ahead Of Time) compiled to fast, predictable, native code. This not only makes Flutter fast, virtually everything (including all the widgets) can be customized.
  • JIT (Just In Time) compiled for exceptionally fast development cycles and game-changing workflow (including Flutter’s popular sub-second stateful hot reload).

4. What is a “widget” and mention its importance in Flutter?

Widgets are basically the UI components likes text, button etc.

5.How many types of widgets are there in Flutter?

1) StatelessWidget : Does not require mutable state.

2) StatefulWidget: Mutable state.

6. Differentiate StatelessWidget and StatefulWidget?

  • Stateless: Widget state creates ONLY ONCE, then it can update values but not state explicitly. That’s why it has only one class which extends with StatelessWidget. They can never re-run build() method again.
  • Stateful: Widgets can update their STATE (locally) & values multiple times upon event triggered. That’s the reason, the implementation is also different. In this, we have 2 classes, one is StatefulWidget& the other is it’s State implementation handler i.e. State<YourWidget>. So if I say, they can re-run build() method again & again based on events triggered.
  • A StatelessWidget will never rebuild by itself (but can from external events). A StatefulWidget can.
  • A StatelessWidget is static wheres a StatefulWidget is dynamic.

7. Explain Stateful Widget Lifecycle in details?

A stateful widget has the following lifecycle stages:

1) createState()

2) mounted == true

3) initState()

4) didChangeDependencies()

5) build()

6) didUpdateWidget()

7) setState()

8) deactivate()

9) dispose()

10) mounted == false

8. What is the difference between “main()” and “runApp()” functions in Flutter?

  • main() function is used to started program.
  • runApp() function should return Widget that would be attached to the screen as a root of the Widget Tree that will be rendered.

9. Hot reload

  • Flutter hot reload features works with combination of Small r key on command prompt or Terminal.
  • You modified your code won’t to be re – executed. This codes are sent into a running Dart Virtual Machine. VM reloads all the update code and libraries.
  • Hot – reload is update classes with new the new of functions and fields, flutter is provide automatically rebuild, re layout the widget tree. It is allowing quickly view the effects of the changes.
  • Hot Reload takes less time thenHot restart.
  • There is also a draw back in Hot Reload, If you are using States in your application then Hot Reload preservers the States so they will not update on Hot Reload our set to their default values.

Limitation of Hot – Reload in flutter.

1) enum

2) class used to constant value (fixed type)

3) Generic types

10. Hot Restart

  • Hot restart is much different than hot reload.
  • In Hot restart it destroys the preserves State value and set them to their default. So if you are using States value in your application then after every hot restart the developer gets fully compiled application and all the states will be set to their defaults.
  • The app widget tree is completely rebuilt with new typed code.
  • Hot Restart takes much higher time than Hot reload.

11.What are the different build modes in Flutter?

  • Debug, Profile and Release

12. What is an App state?

  • State that is not ephemeral, that you want to share across many parts of your app, and that you want to keep between user sessions, is what we call application state (sometimes also called shared state).

Examples of application state:

User preferences

Login info

Notifications in a social networking app

The shopping cart in an e-commerce app

13. key

  • Key is unique identifier of the widget.
  • Use: Two or more Container

Example:Container(key:key(‘ ’))

14. What are keys in Flutter and when to use it?

  • A Key is an identifier for Widgets, Elements and SemanticsNodes.
  • A new widget will only be used to update an existing element if its key is the same as the key of the current widget associated with the element.
  • Keys must be unique amongst the Elements with the same parent.
  • Subclasses of Key should either subclass LocalKey or GlobalKey.
  • Keys are useful when manipulating collections of widgets of the same type.
  • If you find yourself adding, removing, or reordering a collection of widgets of the same type that hold some state, then, you should use a key.

15. await

  • Use: await only use inside the async.
  • It is suspends currently running function until the result is completed. Result is completion pf future.

16. async

  • Modifier
  • Use: Get the data from internet.
  • When body has executed, that returned by result, that result may be error or successful of response.

17. FutureBuilder

  • It is build itself, provide the latest AsyncSnapshots. It is working one type of bridge between Futures and the UI.

18. Fetures

  • Future objects used to Asynchronous operations.
  • If you sometime your bloc long time of operation perform, we did not run the code block as an async the app freeze.
  • Asynchronous operations let your program run without getting blocked.
  • For example: Shopping app

19. What are the similarities and differences of Future and Stream?

Similarity:

Future and Stream both work asynchronously.

Both have some potential value.

Differences:

A Stream is a combination of Futures.

Future has only one response but Stream could have any number of Response.

20. Scaffold

  • The Scaffold instantiates our main structure, usually whatever is consistent across our app like our appbar or navigation, then we’ll set our body to the more interesting part of our app, abstracting it out of runApp will also allow us to use hot reload.

21. Context

  • Context is indicates location of the widget in widget tree.
  • A context only belongs to one widget.
  • Context is a BuildContext instance which gets passed to the builder of a widget in order to let it know where it is inside the Widget Tree of your app.
  • Each widget in Widget tree has own context, and context is directly attached to state of object. Attachment is permeant mean context of the widget will not be change in entire life time of the App.
  • Each widget has its own BuildContext, which becomes the parent of the widget returned by the StatelessWidget.build or State.build function. (And similarly, the parent of any children for RenderObjectWidgets.)
  • Widget we can imaging context in Parent/child manner.
  • Widget tree like Container -> Column -> Text->Button->Image. Here Each Widget in widget tree has own context like Container has it’s own context. Column has it’s own context… same for others. And context is permanent for it’s widget.
  • Container widget known as Parent widget in Widget tree and others are child widgets. So same we can imagine Context of Container widget also know as Parent context and others are child context.
  • State objects with a BuildContext after creating them with StatefulWidget.createState and before calling initState. The association is permanent: the State object will never change its BuildContext. However, the BuildContext itself can be moved around the tree.
  • BuildContext objects are actually Element objects. The BuildContext interface is used to discourage direct manipulation of Element objects.

22. BuildContext

  • A BuildContext is reference to the location of widgets within the tree structure of all widgets which are built.
  • A BuildContext only belongs to one widget.
  • As a State object is associated with a BuildContext, State object is not directly accessible through another BuildContext.

23. Widget

  • Widget as a visual component (or a component that interacts with the visual aspect of an application).
  • Flutter, everything is a Widget, down to the final build.call()
  • Every Widget has its own build() and its context.
  • The BuildContext is the parent of the widget returned by the build() method.
  • BuildContext of the Widget that calls build() is not the same as the build context of the widget returned by build().

24. of()

  • Widgets that want to use the State of inherited widgets need to be able to reference those inherited widgets. This usually comes in the form of the of method.

25. RenderObject

  • When you create any Widget, then widget itself has only configuration information mean If you create Opacity widget then main work of Opacity widget is to manage ‘opacity’ property that either 0 or 1. They don’t care about it’s child. Actually Child is created/Render somewhere else. That’s why we called each time create widget is not more expensive.
  • So we can say Widget is only blue-print, Layout/Rendering has been done somewhere else.

26. Element

  • Element is nothing but instance of the widget at particular location in Widget tree.
  • When widget created, It inflated into Element. And element get inserted it into the tree at particular location.
  • Widget is immutable but element is mutable property.
  • Most of Elements has single child property like, Container, Opacity, Center etc and Some Elements has multiple children call children property. Like Column, Row, ListView and Etc.
  • Element are created by “createElement()” method.

27. Media Query

  • Media query is depends device height and width. That is use to develop the responsive app.

vardeviceSize = MediaQuery.of(context).size;

1) deviceSize.height

2) deviceSize.width

28. IntrinsicHeight

  • When unlimited height is available and you would like a child that would otherwise attempt to expand infinitely to instead size itself to a more reasonable height.

29. Json Mapping

  • Parse json response came from web service.

30. fromJson

  • Every time when we need to parse a single class object.
  • You can find special named constructor .fromJson which constructs class from Map. This map will be created by Dio from endpoint response.

31. path_provider

  • Get the location of the file as TemporaryDirectory and ApplicationDocumentDirectory.

32. How to make androidx app in flutter?

  • flutter create –androidxproject_name

33. Types ofRenderObjectElement in flutter?

1) SingleChildRenderObjectElement. For example Padding(child: ) 2) MultiChildRenderObjectWidget. For example Column(children: )

34. mainAxisAlignment and crossAxisAlignment? OR Row and Column which is same properties?

Row (RHM – Row HorizotanlmainAxisAlignment)

horizontal – mainAxisAlignment

vertical – crossAxisAlignment

Column (CHC – Column HorizotanlcrossAxisAlignment)

horizontal – crossAxisAlignment

vertical – mainAxisAlignment

35. SharedPreferences

  • SharedPreferences is used to storing data key – value pair. We can add int, String, double, List, bool using the SharedPreferences.
  • It is a persistent store data.

36. App change Icon

add dependencies:flutter_launcher_icons

flutter_icons:image_path:’icon/icon.png’

android:true

ios:true

1) flutter pub get

2) flutter pub pub run

flutter_launcher_icon:main

37. Platform Channel

  • Platform channels provide a simple mechanism for communicating between your Dart code and the platform – specific code of your host app. This means you can expose a platform service in your host app code and have it invoked from the Dart code.

38. If you your project ios folder remove your application run or not?

  • Run your application.

39. Type of ListView in flutter?

1) ListView.builder

2) ListView

3) ListView.separated

4) ListView.custom

5) ListView(

scrollDirection: Axis.horizontal,

children: List.generate(filterItemList.length, (index) {});

40. ListView which property use horizontal and vertical data set?

scrollDirection

1) scrollDirection: Axis.vertical,

2) scrollDirection: Axis.horizontal,

Axis is returns horizontal or vertical.

41. Flutter ListView shadow remove or disable?

  • physics: ClampingScrollPhysics(); That is used to multiple listview in flutter application.

42. Types of GridView flutter?

  1. GridView.count()
  2. GridView.builder()
  3. GridView.custom()
  4. GridView.extend()

43. BottomSheet in flutter?

showLoginSheet() {
    _scaffoldKey.currentState.showBottomSheet(
      (BuildContext context) {
returnLoginForm();
      },
elevation: 20,
backgroundColor: Colors.white,
    );
  }

44. When the state changes, widgets …….

rebuild

45. What is the material library which contains Flutter widgets implementing Material Design?

Material.dart

46. What type of widgets are used by Flutter to achieve Pixcel Perfect in iOS UI?

Cupertino

47. Which type of animation allows you In – between animations?

Tweens

48. Which type of animation allows you to represent real – world behaviour?

Physics-based

49. Each widgets is an ……. declaration of part of the user interface?

immutable

50. Skia library is used by flutter for rendering. This helps flutter run fast. What is the other google product which uses Skia for rendering?

Android

51. What type of Widgets are created for dynamic type?

Stateful widget

52. What type of widgets are created for static type?

Stateless widgets

53. Which type of animation is governed by physic laws and forces?

Physics-based

54. Flutter uses ……. compilation to increase the speed while exacting.

Ahead-of-Time

55. What is the name of the Google project to bring flutter or web?

Humming Bird

56. What Library is used for rendering by flutter?

Skia

57. FlutterActivity

  • Activity which displays a fullscreen Flutter UI.
  • FlutterActivity is the simplest and most direct way to integrate Flutter within an Android app.
  • The Dart entrypoint executed within this Activity is “main()” by default. The entrypoint may be specified explicitly by passing the name of the entrypoint method as a String in EXTRA_DART_ENTRYPOINT, e.g., “myEntrypoint”.
  • The Flutter route that is initially loaded within this Activity is “/”.

58. FlutterActivity responsibilities?

  • Displays an Android launch screen.
  • Displays a Flutter splash screen.
  • Configures the status bar appearance.
  • Chooses the Dart execution app bundle path and entrypoint.
  • Chooses Flutter’s initial route.
  • Renders Activity transparently, if desired.
  • Offers hooks for subclasses to provide and configure a FlutterEngine.

59. Eliminates the Use of XML files.

  • Android application develop then work is separated into layout and code. Layout should be written in XML and Views written in java. Since flutter is everything widget.

60. Provider

  • It takes a value and expose it, whatever the value is.

61. ValueNotifier

A ValueNotifier can be used to hold a single value, and notify its listeners when this changes.

62. MobX Pattern

  • MobX is state – management library. That makes to connect the reactive data of your application with the UI. This wiring is completely automatic data feels very natural.

63. MobX principles

  • We have access to an Observable selection of state. (i.e. variables that change over the course of our application).
  • We can display these state items within our view and respond to Action intents.
  • We can modify the state and thus, update our Observable and corresponding views.

64. BLoC

  • The loading state can be represented by the values of a stream inside a BLoC.
  • BehaviourSubject is special stream controller that gives us synchronous access to the last value of the stream.
  • As an alternative to BloC, we could use a BehaviourSubject to keep track of the loading state, and update it as needed.

65. What is the benefit of using the BLOC pattern?

  • Separation of Concerns: The User Interface and the business logic are no longer tightly coupled this makes it easier to make changes to the user interface without or modifying the business logic. It keeps the UI simple and dumb.
  • Testing: It is easier to the Business logic now because we do have to worry about how it fits with the user interface.
  • Reactive Programming: Since the BLOC makes use of streams its helps us take advantage of the operators like distinct, where, asyncMap, switchMape.t.c. They help in writing clean and concise code.

66. What is Stream?

  • Dart is its use of streams for when we have many values being loaded asynchronously and instead of opening a connection once, like with our get request, we can make it stay open and ready for new data.
  • Streams are similar to observables in Rx, LiveData in Android.
  • Sequence of asynchronous events.
  • You define stream at one place, add data to it at some other place and then listen to this data addition elsewhere, so as to refresh your UI etc (like some widget or).
  • You should always close a stream when its task is completed. Otherwise performance issue may arise when an app becomes a complex app or when there are many active streams.

67. StreamController

  • A Streamcontroller is a class provided by Dart in the dart-async package. Streamcontroller is used to create a stream and it provides a sink property to add data (events, variables, network requests) to the stream and also a stream property where you either transform data or listen to the data, errors and done events added to the stream.

RxDart provides three types of StreamContollers

PublishSubject: This is similar to a broadcast StreamController with only one difference that is the stream property returns an Observable instead of a Stream. All rxdartStreamcontroller return Observable instead of a Stream.

BehaviorSubject: This is a special StreamController that captures the latest item that has been added to the controller and emits that as the first item to any new listener. You can also seed the BehaviorSubject with an initial value that will be emitted when no value has been added to the controller.

ReplaySubject: This is a special StreamController that captures all the items that have been added to a controller and emits them as the first items to any new listener. It is possible to limit the number of stored items in the ReplaySubject by passing a maxSize property to its constructor.

68. What is ScopedModel / BLoC Pattern?

  • ScopedModel and BLoC (Business Logic Components) are common Flutter app architecture patterns to help separate business logic from UI code and using fewer Stateful Widgets.
  • Scoped Model is a third-party package that is not included into Flutter framework. It’s a set of utilities that allow you to easily pass a data Model from a parent Widget down to its descendants. In addition, it also rebuilds all of the children that use the model when the model is updated. This library was originally extracted from the Fuchsia codebase.
  • BLoC stands for Business Logic Components. It helps in managing state and make access to data from a central place in your project. The gist of BLoC is that everything in the app should be represented as stream of events: widgets submit events; other widgets will respond. BLoC sits in the middle, managing the conversation.

69. NoSuchMethodError: The getter ‘focusScopeNode’ was called on null?

Basically that is error context.

Navigator.of(context).pushNamed(‘/collections’);

//Navigator.pop(context); //Remove this line

70. Flutter or Dart capitalize first character or word?

StringUtils.capitalize();

71. Arrow Operator in flutter?

Arrow Operator is a short hand in Dart. Only one line of code.

72. What are Null-aware operators?

  • Dart offers some handy operators for dealing with values that might be null.
  • One is the ??= assignment operator, which assigns a value to a variable only if that variable is currently null:
int a; // The initial value of a is null.
a ??= 3;
print(a); // <-- Prints 3.

a ??= 5;
print(a); // <-- Still prints 3.
  • Another null-aware operator is ??, which returns the expression on its left unless that expression’s value is null, in which case it evaluates and returns the expression on its right:
print(1 ?? 3); // <-- Prints 1.
print(null ?? 12); // <-- Prints 12.

73. Flutter keyboard hide, close or dismiss.

FocusScope.of(context).requestFocus(FocusNode());

74. Flutter logout after redirect or move login page? OR How to clear history navigation?

const String loginRoute = '/login';
Navigator.of(context).pushNamedAndRemoveUntil(loginRoute, (Route<dynamic> route) => false);

//route define main.dart
routes: <String, WidgetBuilder>{
      '/': (context) =>SplashScreenPage(),
loginRoute: (BuildContext context) =>LoginPage(),
}

75. Flutter or dart remove single items using BLoC pattern?

List<DispatchResponse>removeJobId = state.dispatchList;
removeJobId.removeWhere((item) =>item.jobId == 'remove unquie id');
yieldstate.copyWith(jobId: null, dispatchList: removeJobId);

76. How to call or define BlocBuilder?

UserBloc _userBloc;
_userBloc = BlocProvider.of<UserBloc>(context);
BlocBuilder(bloc: _userBloc, builder: (context, UserState snapshot) 
   {
return Container();
   })

77. Flutter circle image using assets folder.

CircleAvatar(backgroundImage: ExactAssetImage(imageProfile))

78. Flutter or Dart get current date and time?

final timestamp = DateTime.now();
print('Tag' + timestamp.toIso8601String());
output:
 2019-11-26T10:32:18.236537

79. How to get 2 date difference or calculation?

final timestamp = DateTime.now();
finaltimeToExpiry = timestamp.difference(DateTime.now()).inSeconds;
print('Tag' + timeToExpiry.toString());

80. UserAccountsDrawerHeader set background color in flutter?

UserAccountsDrawerHeader(
decoration: BoxDecoration(
color: Colors.red,
    ),
accountName: Text(sessionUsername),
accountEmail: Text(mail),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.red,
backgroundImage: NetworkImage(gravatarUrl),
    ),
)

81. Flutter TextField or EditText cursor selection end or last display?

TextEditingController.fromValue(TextEditingValue(text: problemList[index].enterValue, 
selection: TextSelection.collapsed(
offset: problemList[index].enterValue.length)))

82. Flutter ListView inside TextField scroll the change, clear, delete, null of the textfield value?

List<TextEditingController> _controllers = new List();
ListView.builder(
physics: constBouncingScrollPhysics(),
itemCount: problemList.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
        _controllers.add(new TextEditingController());
        _controllers[index].text = problemList[index].enterValue;
return Container(); 
      });

83. Flutter Text SingleLine and elipse or dot?

Text(overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle())

84. Flutter text set right side.

Text(textAlign: TextAlign.right)

TextAlign properties:

1)left

2) right

3) center

4) justify

5) start

6) end

85. Dart Isolates?

  • To achieve concurrency, Dart uses isolates, it is works independent don’t share memory but use message communication or passing. Every Dart program uses at least one isolate, which is the main isolate. Dart 2 the Dart web platform no longer supports isolates.

Snapshots

Snapshots are a core part of the Dart VM. Snapshots are files which store objects and other runtime data.

1) Script snapshots

Dart programs can be compiled into snapshot files. These files contain all of the program code and dependencies prepared and ready to execute. This allows fast startups.

2) Full snapshots

  • The Dart core libraries can be compiled into a snapshot file which allows fast loading of the libraries. Most standard distributions of the main Dart VM have a prebuilt snapshot for the core libraries which is loaded at runtime.

3) Object snapshots

  • Dart is a very asynchronous language. With this, it uses isolates for concurrency. Since these are workers which pass messages, it needs a way to serialize a message. This is done using a snapshot, which is generated from a given object, and then this is transferred to another isolate for deserializing.

86. Difference between NetworkImage and Image.network in flutter?

  • NetworkImage class creates an object the provides an image from the src URL passed to it. It is not a widget and does not output an image to the screen.
  • Image.network creates a widget that displays an image on the screen. It is just a named constructor on the Image class(a stateful widget). It sets the image property using the NetworkImage . This image property is used finally to display the image.
  • If you just want to display the image as a widget on screen use Image.network and use NetworkImage wherever an ImageProvider is expected.

87. ExactAssetImage in flutter?

Creates an object that fetches the given image from an asset bundle.

ExactAssetImage(“assets/images/mobile_box.png”)

88. FileImage in flutter?

  • Decodes the given File object as an image, associating it with the given scale. Used to load images from the file system in the target device. E.g. To display a newly downloaded image.

FileImage(file object)

89. Icons a library of predefined icons.

  • BackButton: An icon button for a “back” affordance which adapts to the current platform’s conventions.
  • CloseButton: An icon button for closing pages.
  • AppBar: To show a toolbar at the top of an application.
  • RaisedButton and FlatButton for buttons with text in them.
  • InkResponse and InkWell for the ink splash effect itself.

90. Expanded vs Flexible

91. By default flutter?

MediaQuery

MediaQuery.of(context).padding: 20.0

MediaQuery.of(context).padding.left: 20.0

92. How to make application only portrait mode in flutter

SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitUp]);

93. Android system navigation hide and show in flutter?

SystemChrome.setEnabledSystemUIOverlays([]);

94. didChangeAppLifecycleState() in flutter ?

Called when the system puts the app in the background or returns the app to the foreground.

@override
voiddidChangeAppLifecycleState(AppLifecycleState state) {
}

95. Flutter android v4 library add in .gradle file?

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.android.support:multidex:1.0.3'
}

configurations.all{
resolutionStrategy{
force 'com.android.support:support-v4:28+'
    }
}

96. Dart Map add the value, update and how to get particular key total?

main(){
var map = Map<String, int>();
map.putIfAbsent('2019-07-22', () => 1);
map.putIfAbsent('2019-07-21', () => 2);
map.putIfAbsent('2019-07-23', () => 3);

map.update("2019-07-23", (dynamic val) => 2);

var sum = map.entries
      .where((e) =>e.key.startsWith('2019'))
      .map<int>((e) =>e.value)
      .reduce((a, b) => a + b);

print('sum of total ' + sum.toString());
}

97. Flutter Background Image Scroll Image Scroll Disable?

import 'package:flutter/material.dart';

classSignUpView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
return Stack(children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/background.png"),
fit: BoxFit.cover,
      ))),
Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
appBar: AppBar(
title: Text('NEW USER'),
backgroundColor: Colors.transparent,
elevation: 0,
          ),
body: Padding(
padding: EdgeInsets.all(10),
              child: ListView(children: <Widget>[])))
    ]);
  }
}

98. CircleAvatar change the background color in flutter?

CircleAvatar(
backgroundColor: Colors.black.withOpacity(0.2), 
backgroundImage: new FileImage(), radius: 65.0)

99. flutter get extention and file name form file?

add dependency: path

extension(file.path); //extention

basename(file.path); //filename

100. What is Flutter inspector?

The inspector is powerful tool for visualizing and exploring Flutter these widget trees. It is very useful 1) Understanding existing layouts 2) Diagnosing layout issues.

Advantage

1) Select widget mode

2) Refresh widget

3) Show/hide performance overlay

4) Toggle platform

5) Show debug paint

6) show paint baselines

7) Enable slow animations

101. What is different static, final, dynamic and const in dart?

  • static access – Member is available on the class itself instead of on instances of the class.

That’s all it means, and it isn’t used for anything else. static modifies members.

final

single-assignment.

final variable or field must have an initializer. Once assigned a value, a final variable’s value cannot be changed.

final modifies variables.

const

const modifies values.

const variables are implicitly final.

You can use it when creating collections, like const [1, 2, 3], and when constructing objects (instead of new) like constPoint(2, 3).

const means that the object’s entire deep state can be determined entirely at compile time.

Once you assign value to a const or final variables, you cannot change it.

getConst() =>const [1, 2]; 
main() { 
var a = getConst(); 
var b = getConst(); 
print(a === b); // true 
}

An instance variable can be final but cannot be const.

If you want to make a Constant at class level declare it as static const not only const.

dynamic

If a variable is declared dynamic its type can change over time.

dynamic a = "abc"
a = 123; 
a = true; 

If you declare variable as a var, once assign type can not change.

var b = "flutter";
b = "flutter tutorial"; //This will not compile

102. Firebase file upload save the file new name?

StorageReferencestorageRef = FirebaseStorage.instance.ref().child(new name);

103. How to add or insert data in firbase with database reference id using flutter?

finaldatabaseReference = Firestore.instance.collection('/');
awaitdatabaseReference.document('unique id set').setData({
      'id': '1',
      'status': 'true'
    });

104. Firebase notification background message get application is close?

onBackgroundMessage using.

105. Firebase upload image, file using flutter and How to get upload file url?

var path = multipleUpload.file.path;
var filename = path.split("/").last;
StorageReferencefirebaseStorageRef = FirebaseStorage.instance.ref().child(filename);
StorageUploadTaskuploadTask = firebaseStorageRef.putFile(multipleUpload.file);
StorageTaskSnapshottaskSnapshot = await uploadTask.onComplete;

Print(uploadTask.isComplete);
String downloadUrl = await taskSnapshot.ref.getDownloadURL();
print('Display image URL path' + downloadUrl);

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in