Preparing for and Succeeding in the Job Interview
Preparing for and Succeeding in the Job Interview
But how do you prepare for a Flutter interview if you have never had one? What can you expect the process to look like? What kinds of questions will you be asked? What kind of questions should you ask? How do you answer the question, so, what are your compensation expectations?
For many of us, the process can be daunting, but fear not! In this chapter, we are going to break down the entire process, start to finish, and make sure that you have got all the tools you need going into the interview to be successful — and land that job!
Chapter overview
Structure
- The interview process, start to finish
- What to expect during a technical interview
- Culture fit interview: Evaluating a company and being evaluated
- Negotiating compensation
- Answering some interview questions
- Accepting your first Flutter job
Objectives
The interview process, start to finish
Interviewing for a technical role, such as that of a Flutter developer, is quite different than interviewing for other types of non-technical jobs. Typically, the interview process will be broken down into about four to five discrete sections, spanning multiple days and often with several different people. This may sound daunting, but once we break it down, you will understand why this is.
Initial conversation
The first part of the interview process is typically a brief, initial conversation where you will speak to a non-technical person, such as somebody from the human resources team. If you are collaborating with a recruiter, this step may be omitted as this exploratory phase would have been done between you and the recruiter, as well as between the recruiter and the company. This conversation is where interest between the employer and you, as a candidate, is established. You will be asked questions like, so, how did you hear about our company? They will typically leave room for you to ask questions, as well.
You can expect this to be a light, casual conversation where you will talk about your educational and technical background at a high level, and you will hear more about the business, what it is they do, and where you might fit in with their team. Have fun with this one! Just remember to stay professional. Often, this first conversation will end with setting up a time for a first technical interview, although that may come later in some instances.
Technical interview
The next step of the interview process is usually the technical interview. This might be a single meeting, or it might be broken into two separate discussions with some coding done in between. We will talk more about this process in a little bit since it is going to be the bulk of the interview process.
Culture-fit conversation
After the technical interview usually comes a culture-fit conversation. By this point, the company is confident in your technical abilities and is interested in making sure that you will get along with the team. You will probably meet with several people from across the whole team that you will be working with should the offer of employment be extended. They might be interested in your hobbies and interests outside of Flutter. Primarily, what they are looking for is whether your personality, work style, ethics, and core values align with the company's.
This may be the most important part of the interview, as working for a company where you do not share the same values, or you work in a way that is at odds with the rest of the company would make for a miserable experience for both you and the company. That is why we are going to talk about this much more in-depth later in this chapter.
Job offer
The final part of the interview process is the job offer itself. This is where compensation and titles will be discussed, as well as any benefits the company may offer. Compensation is not just an hourly or salary wage, though. Depending on the role and company, it may include stock options, a 401(k) (retirement) plan, stipends for attending conferences, an allowance for purchases related to the job, or many other benefits. We will discuss this more later in the chapter, as well.
Now that you know what to expect broadly during the interview process, let us look more closely at the areas we called out earlier, starting with the technical interview.
What to expect during a technical interview
The goal of a technical interview is to evaluate your critical thinking skills and whether you can translate your thought processes into code that is well-structured and reasonably correct. They want to know how you think and whether you can explain your thought process.
It is ok not to know the answer to every question they ask, but be careful about saying, I do not know. Doing so does not give the interviewer much to work with to help them get things back on track. Not knowing an answer is not a dealbreaker by any means, but not managing the stress and pressure of the interview process effectively could show them that you might not be able to do your job under pressure, either.
In your technical interview, they are likely to ask you to complete some sort of task, then expect you to talk through the problem, devise a solution, and write some code to accomplish it. There are several different ways by which this can be accomplished:
Whiteboarding
Online coding challenge
Take-home exercise
Usually, the technical interview will involve two or more people from the company you are interviewing with. You should expect the hiring manager and a senior member of the team. They will be evaluating you for more than your technical abilities and critical thinking skills, so be personable and feel free to engage in the non-technical banter at the beginning of the interview process.
The culture fit interview: evaluating a company and being evaluated
The interview process is more than just a company evaluating you. It is also about you getting to know them. As we discussed before, the usual next step after a technical interview is a culture-fit conversation. This might be the most important part of the interview, because if you and your potential employer and/or new team do not work well together, things simply will not work out, and you will be back to looking for a new job in no time.
So, how do you prepare for a culture-fit interview? It starts by understanding what is important to you. Take some time to sit and write down the answers to these questions:
- What sort of environment do I need to do my best work? (Is it a quiet, dimly lit environment? A cubicle where coworkers can pop in to ask a question at any time? Fully remote, so you can wear pajamas all day?)
- What sort of company do I want to work for? (Do you feel comfortable working for a company that contributes to accelerated climate change? Is it important for the company to contribute to the community, by offering volunteer opportunities, contributing to open-source projects, or offering public workshops?)
- How many meetings are too many meetings? (Some companies have a lot of meetings — how many is too much for you? Do you prefer a structured environment where policy and procedure are all spelled out, or a fast and loose culture, where things are figured out on the fly?)
- What sort of accommodations are important to me? (Does the company need to be ADHD-friendly? LGBTQIA-friendly? Wheelchair accessible?)
- How important is it for an employer to offer me a path to grow? (Are you content being hired somewhere where you are never mentored or given the opportunity to expand your skillset? What about being offered a way to transition to a different type of role, such as management?)
- What does my ideal boss look like? (What qualities might they have? Are they hands-on or laid back?)
- How do I prefer to get feedback? (Do you prefer informal meetings or performance reviews?)
- Do I prefer to work alone or as part of a team? (If you prefer working on a team, what size team?)
- How do I handle stress? (Are you cool and calm under pressure, or do you totally break down? How might this affect how you interact with a team? What sorts of questions might you need to ask?)
- How important is work-life balance to me? (Some people are built to work all the time. Others have families and enjoy taking their evenings and weekends to spend time with friends or doing hobbies.)
- What motivates me? (Are you motivated by solving complex problems? Receiving a reward, such as praise? Do you enjoy teaching or learning?)
- What is my ideal work schedule? (Do you work best in the mornings? At night? Certain days during the week? Do you prefer to work all year and take a few weeks off during the summer for a long vacation?)
- What is my long-term plan? (As cliché as it sounds, think about what your 5-year and 10-year plans are. Where do you envision yourself?)
Hopefully, by answering these questions, you will spark further inspiration to ask yourself even more questions. Knowing yourself well enough to know what it is you want, need, and what your goals are will help you evaluate a company to figure out if you would be a good fit there.
Culture fit
Culture add
- Explore the company's social media and any news about them.
- Visit their website: many companies have a section on the website about their mission.
- Check sites such as Glassdoor to see what employees are saying about working there.
- Reach out to current and past employees to ask for their perspectives.
Negotiating compensation
If both you and the employer walk away from the culture fit portion of the interview feeling confident, the next step is likely receiving a job offer. What sort of compensation you are offered will vary widely based on things such as geographic location, size of the company, whether the company is a startup or publicly traded, whether you are a contractor or full-time employee, and your own experience.
You will either be offered an hourly or salary wage, and anything after that will vary. In some countries, with some employers, depending on the role, you may be offered:
- a retirement plan
- private health insurance
- stock options
- a wellness budget to join a gym
- a conference allowance to travel to a relevant technology conference once a year
- a technology budget for things like a laptop, an external display, a mouse/keyboard, or sometimes even a desk and chair
You will have to figure out what part of a compensation package is most important to you. Are you being offered private health insurance but are covered by your spouse? You may be able to negotiate a higher salary instead. Perhaps you are interested in receiving more shares in the company. You could trade some of your salary for those additional shares.
When it comes to the wage, you will have to do your own research to understand the current market rates for a developer with your skillset in the position you are applying for. Sites like Glassdoor may list wages for other employees at the company in your role or an adjacent one. Try not to price yourself too high or too low. If you have been collaborating with a recruiter, you should be having these sorts of compensation conversations, and they will be able to help you navigate the process.
Answering some interview questions
Let us seek to answer some interview questions you will likely have to prepare for, starting with all the questions in this book.
build() method is run each time Flutter needs to draw a widget to the screen. The build() method will always return a widget, which is generally composed of other widgets. The resulting widget will be added to the widget, element, and render trees.There are several ways to figure out what properties are available for any given widget:
- The quickest and easiest way is to simply hover your mouse cursor over the widget in question. By doing so, the widget's documentation will appear, outlining the available properties, as well as some other documentation.
- You can also refer to the documentation online by searching https://flutter.dev for the widget name.
- The third way is to go to the widget's definition by holding Ctrl/⌘ and clicking on it. Once there, you will be able to explore not only the properties available, but how they are used within the widget, as well.
String and the other a bool, passing the bool before the String will cause the widget to fail to build. However, if those parameters are converted to named parameters, the order no longer matters.Named parameters are wrapped in curly braces {}. Positional parameters are not. In the following example, the parameter text is a positional parameter, whereas isActive is a named parameter. The value passed into either a positional or named parameter is called an argument.
class Test extends StatelessWidget {
final String? text;
final bool? isActive;
const Test(this.text, {this.isActive, super.key});
@override
Widget build(BuildContext context) {
return Text('$text $isActive');
}
}
String? can either be a String or null. However, a String can never be null.A Key is used by the framework to match a widget with other widgets when a rebuild is triggered. It can be useful to set a Key when you need to preserve a widget's state as it moves around the widget tree. In practice, it is rare to manually specify a Key; however, it can be a useful tool, especially when writing tests, as it will enable you to find a widget more easily in the widget tree programmatically.
If you find yourself modifying a collection of widgets of the same type that hold some sort of state, it is time to add a Key. (Think: reordering a to-do list, where the state holds a checkbox.) There are several types of keys, such as LocalKey, GlobalKey, and UniqueKey. Learn more about Keys from the official Flutter documentation, which you can find here: https://api.flutter.dev/flutter/foundation/Key-class.html.
part and part of keywords.createState()mounted == trueinitState()didChangeDependencies()build()didUpdateWidget()setState()deactivate()dispose()mounted == false
A stateless widget would not update once the widget is added to the widget tree. If the properties which were used to create it change by way of a parent widget passing down new properties, the widget will be discarded, the associated element in the element tree will be updated, and a new widget will be created before being inserted into the widget tree in place of the previously discarded widget.
In contrast, a stateful widget can maintain its own state and allows for the mutation of its properties. A stateful widget will rebuild whenever the state is changed and setState() is called.
Inherited widgets are accessible via BuildContext and allow you to access their properties from any widget, which is an ancestor in the widget tree. Common inherited widgets you will find are MediaQuery, Theme, and Navigator.
context that looks it up "must be a descendant of the InheritedWidget" (Flutter, n.d.-a). Of the three examples, only MediaQuery is one (it extends InheritedModel, a kind of InheritedWidget). Theme is a StatelessWidget that builds a private inherited widget, _InheritedTheme, which Theme.of reads. Navigator is a StatefulWidget, and Navigator.of finds its NavigatorState with context.findAncestorStateOfType<NavigatorState>(), not through an inherited widget (flutter/flutter, n.d.).BuildContext contains information about where a widget is in the widget tree. When a widget is rendered, it is part of the widget tree and has a corresponding RenderObject in the element tree. RenderObjects are an implementation of Element, which implements BuildContext.
BuildContext (abstract class Element extends DiagnosticableTree implements BuildContext), and every widget in the tree has one in the element tree. A RenderObject is not an Element: it is a node of the separate render tree, and only the elements of render object widgets (RenderObjectElement) create and hold one (flutter/flutter, n.d.).build method of a widget) as an argument to a parameter, which will be called from inside that function, but will run in the scope of the parent widget. For example, a button will have an onPressed callback function. When the button is pressed, the onPressed callback function will run.OutlinedButton, use the OutlinedButton.icon constructor rather than by supplying the icon as a child of the button.To style a button, you should either add a style to the button itself or add your style to the Theme. Button style parameters expect a MaterialStateProperty object, which will resolve the various states of a button (neutral, pressed, disabled, and so on) into a style. Refer to the documentation on the Flutter website for more information. You can find that here: https://api.flutter.dev/flutter/material/ButtonThemeData-class.html.
MaterialStateProperty is deprecated: "Use WidgetStateProperty instead. Moved to the Widgets layer to make code available outside of Material. This feature was deprecated after v3.19.0-0.3.pre." The linked ButtonThemeData themes the legacy buttons and "is planned to be deprecated in a future release"; the TextButton, ElevatedButton and OutlinedButton families are themed with TextButtonThemeData, ElevatedButtonThemeData and OutlinedButtonThemeData instead (flutter/flutter, n.d.).onPressed method is null. This is typically done by checking some sort of state or variable, then returning a method when the appropriate conditions are met.GestureDetector not only allows you to turn a Container into a button but allows you to perform all sorts of swipe, tap, drag, pinch, and other gestures.GestureDetector, you would be right! There are other widgets that implement this functionality, too, such as Dismissible.keyboardType property, which takes in a TextInputType object. To display a keyboard tailored for numerical input, use keyboardType: TextInputType.number.List<TextInputFormatter> of your text input's inputFormatters property.FilteringTextInputFormatter to only allow the characters you want, using a RegExp.DateTime objects can be added to or subtracted from using the add and subtract methods, which take a Duration object. The current date/time can be generated using the now constructor. DateTime.now().add(const Duration(days: 365)) would result in a DateTime object with a time precisely one year in the future.
final now = DateTime.now();, use DateTime(now.year + 1, now.month, now.day).The Material date picker is much simpler to implement, requiring minimal setup work, whereas the Cupertino date picker needs to be placed within a modal popup to position it appropriately on the screen. The Material date picker can quickly switch between time and date options, while the Cupertino date picker needs to be told what mode to operate in.
Finally, the Cupertino date picker can be used to select more than just a date/time. It is also capable of displaying arbitrary lists of data to pick from, such as choosing a day of the week, or a duration for a timer.
List if so desired. See Chapter 5: Handling User Input for an example.true and false. However, if tristate: true is set, a third option of null becomes available. A checkbox will become disabled if the onChanged argument is null.min and max properties.Form groups together several input widgets, allowing you to specify a Key to save, recall, reset, and validate all the inputs at once. If you only have one input, a Form is not necessary.TextFormField is a TextField that is wrapped in a FormField, which allows you to use the onSaved and validator methods.validator function on any widget with a FormField.pubspec.yaml file is written in the YAML markup language.name: Used to name the package.version: Used to define what the application's version number is.environment: Used to define which version of Flutter/Dart the project relies upon.
Other directives include description, publish_to, dependencies, and dev_dependencies. Both dependencies and dev_dependencies are required for Flutter projects. They define what packages are used within the project and which versions of those packages to use.
name as "Required for every package" and environment as "Required as of Dart 2"; version and description are only "Required for packages that are hosted on the pub.dev site". dependencies "Can be omitted if your package has no dependencies", and dev_dependencies "Can be omitted if your package has no dev dependencies" (Dart, n.d.-a). A Flutter project still lists flutter: sdk: flutter under dependencies in practice, as the projects created by flutter create do.dart pub upgrade --major-versions to upgrade your packages to the latest resolvable versions.assets directive within the flutter directive.Dependencies can be pinned to a specific version by omitting the caret (^) in front of the version number. If the caret is present, the package can be upgraded to newer versions that fall within the dependency constraints. For example, a version of ^2.1.0 could be upgraded automatically to any version, provided it was still in the 2.1.x version range, such as 2.1.9. Learn more about package versioning here: https://dart.dev/tools/pub/versioning.
^version means the range of all versions guaranteed to be backwards compatible with the given version" (Dart, n.d.-b). So ^2.1.0 means >=2.1.0 <3.0.0, and 2.9.0 is allowed as well as 2.1.9.Pub Points are a measurement of the quality of a package based on numerous criteria. These criteria are ever-evolving, but as of writing they are as follows:
- Follow Dart file conventions (30 points total)
- Provide a valid
pubspec.yaml(10 points) - Provide a valid
README.md(5 points) - Provide a valid
CHANGELOG.md(5 points) - Use an OSI-approved license (10 points)
- Provide a valid
- Provide documentation (20 points)
- Provide an example usage of the package (10 points)
- 20% or more of the public API has
dartdoccomments (10 points)
- Provide support for all 6 platforms (20 points)
- Pass static analysis (code has no errors, warnings, lints, or formatting issues) (30 points)
- Support up-to-date dependencies (20 points)
- Dart 3 and Flutter 3.10 compatibility (20 points)
The total number of points a package can have, as of writing, is 130. Find out more about how Pub Points are calculated here: https://pub.dev/help/scoring#pub-points.
just_audio.The home screen of pub.dev includes a list of the most popular packages and the top packages on Pub.
Use a package such as shared_preferences, encrypted_shared_preferences, or isar to store data on the device's local storage. Then, read that data the next time the app launches.
isar's maintenance before depending on it. When this page was written (November 2026), its latest stable version on pub.dev, 3.1.0+1, had been published three years earlier, with only 4.0.0-dev prereleases after it (pub.dev, n.d.-b).Future. A future is a promise that, once the work has been completed, a value will be returned.Synchronous code is blocking, whereas asynchronous code is non-blocking. Blocking code prevents the execution of other steps from taking place, whereas non-blocking code allows processing to continue while the non-blocking code is run in the background.
Future and Stream code takes turns on that one thread, and only separate isolates "enable parallel code execution on multiple processor cores" (Dart, n.d.-c). While an asynchronous operation waits, for example on file I/O, other code runs.async is used to mark a method as a long-running, non-blocking process. The await keyword is used to wait for an async function to complete and return its value.Future<T>.http package is a fine choice. If you need additional options which the http package does not offer, Dio is an excellent alternative.HTTP status codes are metadata returned from the remote endpoint to convey information about how a request was (or was not) completed.
- Status codes in the 100 range are informational messages,
- codes in the 200 range are success messages,
- codes in the 300 range are redirection messages,
- codes in the 400 range are client error messages,
- and codes in the 500 range are server error messages.
Read about HTTP status messages here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.
if statement to catch errors early and halt processing as soon as one is found, rather than wasting time on further processing of data that is known to be invalid.JSON, or JavaScript Object Notation, is a key-value-based representation of data. In Dart, it is either a Map<String, dynamic> or a List<dynamic>, depending on the JSON's structure.
When using print or log to dump an API response to the console, any value which is a String will be stripped of its enclosing quotes. This can make it difficult to use these tools to analyze API responses. For this reason, prefer using DevTools to inspect responses.
POST: Used to send data to an API. Sending multiplePOSTrequests would result in the server processing each request individually. (Think: making multiple orders at a restaurant.)GET: Used to retrieve data from the server.PUT: Nearly the same as thePOSTmethod, except that it is idempotent. Sending multiplePUTrequests will have the same effect.PATCH: Used to modify an existing resource on the server. The resource must have been previously created with aPOSTorPUTbefore it can be modified with aPATCH.DELETE: Asks the server to remove a resource.
- C —
POSTorPUT - R —
GET - U —
PATCH - D —
DELETE
Use List<int>.generate to generate the list. Then, check each value to verify it is odd:
List<int>.generate(37, (i) => 2 * i + 27).where((i) => i.isOdd).toList();
builder has an AsyncSnapshot value which will have a connectionState property equal to ConnectionState.done.If your list of widgets needs to be scrollable, prefer a ListView for performance reasons. If you are stacking a small number of related widgets which do not need to be independently scrollable, opt for a Column.
ListView cannot return the different widgets you need to display, investigate Flutter's many Sliver widgets.showDialog method where you can use the builder to display a Dialog object.Dialog, pass the value back like this: Navigator.pop(context, value); where value is equal to a Boolean value that references your chosen option.async/await. The async* keyword means the function will yield multiple values as a stream of events. This is called an async generator.StreamBuilder is the async* equivalent to async's FutureBuilder.The dart:async library provides widgets that work with sinks and streams.
dart:async contains no widgets. It provides the classes Future, Stream and StreamController (as Chapter 7 notes, StreamController is "A controller with the stream it controls", not a widget (Dart, n.d.-d)). The widgets that work with them, StreamBuilder and FutureBuilder, come from Flutter's widgets library (package:flutter/widgets.dart) (flutter/flutter, n.d.).StreamController to a variable. Then, use the .sink.add method on the variable.Navigator widget, whereas Router is used for declarative routing.Navigator is a much simpler method of routing than Router, making many of the more complex tasks that Router provides much more difficult to accomplish. While technically capable of doing anything Router can, as Router is built using Navigator, many tasks, such as nested routing and deep linking, are better suited for a more complex routing system.routes property of your MaterialApp, and then you can switch from Navigator.push to Navigator.pushNamed.Navigator.push will add the new route to the top of the routing stack. Navigator.pushReplacement will replace the current route with the new one.onGenerateRoute method. Getting data back from a route can be done by awaiting the navigated route and passing a value back from the pop method.Hero widget can be used to animate a widget from one screen to another.The ValueChanged widget will trigger a rebuild of the widget when a value is changed, then the notifyListeners() method is called. This is useful when you want to trigger a widget rebuild from another widget within your application.
ValueChanged is not a widget. It is a typedef for a callback, typedef ValueChanged<T> = void Function(T value), a "Signature for callbacks that report that an underlying value has changed" (Flutter, n.d.-b). It triggers no rebuild by itself; in the Router API app, the rebuild comes from the RouterDelegate, whose callback calls notifyListeners().RouterDelegate is used with the Router API to define the behavior of how the Router learns about and responds to changes in the routing state.createRoute method of a Page to return a PageRouteBuilder with the new animation being defined within the pageBuilder property.To prevent a ListView from scrolling, pass both the shrinkWrap: true and physics: const ClampingScrollPhysics() parameters to it. Note that this will effectively turn your ListView into a Column, thereby eliminating any performance improvements gained by using a ListView.
ClampingScrollPhysics does not stop scrolling. It is the "Scroll physics for environments that prevent the scroll offset from reaching beyond the bounds of the content", typical of Android. The physics that stops it is NeverScrollableScrollPhysics, "Scroll physics that does not allow the user to scroll" (flutter/flutter, n.d.): physics: const NeverScrollableScrollPhysics(), as the runnable copy of Chapter 11 uses to hand the drag to the parent.String can be represented as part of that String. For example, a String with a dollar sign in it would normally cause Dart to evaluate the next word as a variable name, replacing both the dollar sign and word with the value of the variable. If you would rather have the dollar sign as part of your String, you would prepend the dollar sign with a backslash (\).Interpolation is used to evaluate complex variables or methods directly inside a String. It is often used to evaluate a single property of an object, such as with "Hello, ${user.name.first}!" or by directly invoking a method call, like this: "Hello, ${getUsersFirstName(user)}!". It can also be used to escape a quote that would otherwise break the String definition, such as this: 'That\x27s great news!'.
\x27 is not interpolation but an escape sequence (Question 93): \x followed by two hexadecimal digits stands for that character code, here '. 'That\'s great news!' escapes the quote the same way; interpolation is only the $name and ${expression} form.ValueChanged is a typedef defined as typedef ValueChanged<T> = void Function(T value). It is used to trigger rebuilds when a value changes, often in an InheritedWidget.
ValueChanged triggers nothing by itself: it is the "Signature for callbacks that report that an underlying value has changed" (Flutter, n.d.-b). Whatever function is passed in decides what happens, for example a setState call or a notifyListeners() call (see Question 86).typedef is a way of specifying a new type without defining an object class. The type could be a method call, a different object, or something similar. An example of a typedef is typedef ListOfInts = List<int>;. This would allow one to use ListOfInts in any place that List<int> could be used.List in which the contents cannot be modified. It guarantees that a List would not be changed, allowing for performance improvements, and preventing accidental discrepancies in data.ChangeNotifiers to notify listeners about updates to the state, compared to the events being emitted from BLoC and values being streamed from a Cubit...method calls strung together. Note the double period, known as a cascade operator.LayoutBuilder widget can be used to build a responsive layout.enum, then using a switch case to ensure you do not forget any of the values.This package is used to deal with files, directories, processes, sockets, WebSockets, and HTTP clients/servers.
dart:io is not a package but one of Dart's core libraries, "the dart:io library", which you import with import 'dart:io'; (Dart, n.d.-e).To manually update the app icon, you will be modifying resources in each native platform's configuration. The Flutter documentation has information on how to do this, here: https://docs.flutter.dev/development/ui/assets-and-images#updating-the-app-icon.
The Flutter documentation has helpful resources for designing a splash screen. You can read more here: https://docs.flutter.dev/development/ui/advanced/splash-screen.
The flutter_native_splash package will help you update both your app icon and the splash screen.
flutter_native_splash generates the splash screen only. Chapter 10 uses a second package, flutter_launcher_icons, for the app icon.- The
yarupackage will help you build applications that feel at home on Ubuntu Linux, - whereas the
adwaitapackage will feel at home on any Linux distribution using Gnome as the desktop environment. - Microsoft's modern design language, Fluent, can be replicated using the
fluent_uipackage. - Apple's desktop-styled widgets can be found in the
macos_uipackage.
The Theme widget is an inherited widget that contains information about the currently targeted platform via Theme.of(context).platform.
Theme is a StatelessWidget; the inherited widget it builds is the private _InheritedTheme, which Theme.of(context) reads (see Question 11). Theme.of(context).platform works as stated (flutter/flutter, n.d.).flutter_platform_widgets package will allow you to build applications that use different widgets depending on which platform the application is running on.- I. Ensure the error is reproduceable. If the error is intermittent, you have not properly identified the error.
- II. Be certain that the problem you are debugging is the problem you need to solve.
- III. Check all the obvious error sources. It is easy to waste time by debugging a “complex” problem that turns out to have a very simple and obvious solution.
- IV. Debug the problem: isolate the problem by dividing it into working versus non-working components. Think like a computer: step through the instructions one at a time to find where the operation fails.
- V. If you are unable to identify the root cause of the problem, reassess the situation: what assumptions have you made that might be incorrect? Walk through the process again, taking notes and using knowledge learned from the last time.
You can log information to the debug console using the print, debugPrint, and log (from the dart:developer package) methods.
dart:developer is not a package but a Dart core library; you import it with import 'dart:developer'; and add nothing to pubspec.yaml.Exception class that can be thrown when an exception occurs. This class contains information about the problem.catch portion of the try/catch block. A try/catch can also obfuscate problems if not written correctly, making debugging more difficult.flutter run command will provide a URL you can access in your browser.vsync period, jank will occur, causing hitching in the interface.- Debug mode: The default mode for developing applications in. This mode allows full access to many of the debugging tools that Flutter provides, including hot reload.
- Profile mode: Used to assist in evaluating the performance of an application, unlocking the ability to use the Performance page in DevTools.
- Release mode: Strips out the debugging and performance tooling used by Flutter, maximizing the performance of the application in preparation for release.
shrinkWrap: true property to a ListView, it essentially becomes akin to a Column, losing all performance benefits that a ListView would otherwise give you.- Make sure the
build()method is not doing more work than it needs to. This method can run on every single frame if you are scrolling or animating and should not run expensive operations. - You can also use caching to store values that would otherwise be re-fetched from external sources.
- One of the biggest things you can do to optimize performance is to simply break down large widgets into smaller ones and ensure you are passing only the necessary data to build a widget, rather than a larger object.
Ask yourself the following questions:
- Does this API provide the data I require for my application?
- What is the cost of using this API?
- Is the provider reputable and expected to be around for a long time?
enum is a Dart type that represents a fixed list of constants.A decorator, such as @override, is used to add additional behavior to an object without affecting other objects of the same class.
@override a metadata annotation: you "use metadata to provide additional static information about your code" (Dart, n.d.-f). An annotation adds no behavior by itself; tools such as the analyzer or a code generator read it. Adding behavior to one object without affecting others of the same class is the decorator pattern, a different idea: an object that wraps another object.LooksLikeThis, whereas camel case looksLikeThis.Secrets can be stored as environment variables, which are not stored in source control. At runtime, the variable can be read in and compiled automatically.
flutter_dotenv README puts it this way: "Values loaded by this package should be treated as public client-side configuration" (flutter_dotenv, n.d.).This book is a fantastic resource for many Flutter questions! There are many online resources dedicated to answering questions, too. Always start by reading the documentation before asking your questions to others, as it may save you (and others) a lot of time. If you are part of a developer community, you have already got a great resource at your fingertips. Otherwise, sites like Stack Overflow or even ChatGPT can answer your questions.
async/await operations are not blocking. When an async function is invoked, Dart will mark it as inactive and continue processing other code until the function returns a value, at which point it will be marked as active again.Dependency injection allows you to decouple objects, rather than hard-coding them. For example, you may have a widget that takes in a parameter for an API that it uses to make an API call. When creating the widget, you could pass the API object directly in, thereby coupling the API directly to the widget. However, this would make it difficult, if not impossible, to write tests where the API response is mocked.
By registering the API class in a dependency injector, you can pass the instance of the API, which has been registered into the widget. Then, when writing a test, you can inject a different API, which you can use to mock responses.
- Model View Controller (MVC): Separates data (Model), user interface (View), and application logic (Controller).
- Model-View-ViewModel (MVVM): Separates user interface (View) from business logic (Model) and presentation logic (ViewModel).
- CLEAN: A set of principles designed for building scalable, maintainable, and testable software. Read more here: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html.
Flutter is declarative, rather than imperative. Read more in the documentation, here: https://docs.flutter.dev/get-started/flutter-for/declarative.
Conclusion
Interviewing for technical roles can be daunting, but with the tools and resources available to you in this chapter, you will be more than prepared to tackle it. Getting your first job offer as a Flutter developer is going to be a huge accomplishment for you, and after working so hard to get to that point, you deserve to feel proud!
Once you have accepted your job, you have got a whole new journey ahead of you. In the final chapter, we are going to talk about what it takes to be successful in your new role, as well as what you will need to do to grow in your career.
References
- Dart. (n.d.-a). The pubspec file. Retrieved from Dart: https://dart.dev/tools/pub/pubspec (added, not in the book)
- Dart. (n.d.-b). Package dependencies. Retrieved from Dart: https://dart.dev/tools/pub/dependencies (added, not in the book)
- Dart. (n.d.-c). Concurrency in Dart. Retrieved from Dart: https://dart.dev/language/concurrency (added, not in the book)
- Dart. (n.d.-d). StreamController class. Retrieved from Dart API: https://api.dart.dev/dart-async/StreamController-class.html (added, not in the book)
- Dart. (n.d.-e). dart:io. Retrieved from Dart: https://dart.dev/libraries/dart-io (added, not in the book)
- Dart. (n.d.-f). Metadata. Retrieved from Dart: https://dart.dev/language/metadata (added, not in the book)
- Flutter. (n.d.-a). InheritedWidget class. Retrieved from Flutter API: https://api.flutter.dev/flutter/widgets/InheritedWidget-class.html (added, not in the book)
- Flutter. (n.d.-b). ValueChanged typedef. Retrieved from Flutter API: https://api.flutter.dev/flutter/foundation/ValueChanged.html (added, not in the book)
- flutter/flutter. (n.d.). framework.dart, navigator.dart, theme.dart, media_query.dart, material_state.dart, button_theme.dart, scroll_physics.dart and async.dart (Flutter 3.29.0 source). Retrieved from GitHub: https://github.com/flutter/flutter/tree/3.29.0/packages/flutter/lib/src (added, not in the book)
- flutter_dotenv. (n.d.). flutter_dotenv. Retrieved from pub.dev: https://pub.dev/packages/flutter_dotenv (added, not in the book)
- pub.dev. (n.d.-a). Scoring. Retrieved from pub.dev: https://pub.dev/help/scoring (added, not in the book)
- pub.dev. (n.d.-b). isar. Retrieved from pub.dev: https://pub.dev/packages/isar (added, not in the book)
- pub.dev. (n.d.-c). pub.dev (home page). Retrieved from pub.dev: https://pub.dev/ (added, not in the book)
Finding Flutter Jobs
How the Flutter community and recruiters bring jobs to you, and 16 recruiter answers on skills, resumes, seniority and compensation.
Your Road Ahead
Preparing for your first Flutter job, working in Scrum or Waterfall teams, the skills still to learn (version control, testing, animation) and growing your career.