0% found this document useful (0 votes)
2 views

Flutter Coding Assessment 1

Uploaded by

mihirss555.ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Flutter Coding Assessment 1

Uploaded by

mihirss555.ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

4/22/25, 11:34 AM Flutter Coding Assessment

Flutter Coding Assessment


This assessment evaluates your Flutter skills through coding challenges, UI building, form validation,
API integration, and debugging tasks. Focus on writing clean, functional, and bug-free code.

Note: You are required to attempt a minimum of 5 challenges.


Give it your best shot, good luck!

Candidate Name *

Avinash gupta

Coding section

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 1/11
4/22/25, 11:34 AM Flutter Coding Assessment

1. Error Debugging (Basic)

Question:
The following code throws an error at runtime. Identify and fix the error.
<Code>
class MyWidget extends StatelessWidget {
final title;

MyWidget(this.title);

@override
Widget build(BuildContext context) {
return Text(title);
}
}
</Code>

Expected Skill: Understanding of null safety and widget structure.

class MyWidget extends StatelessWidget {


final? title; //made changes

MyWidget({this.title});

@override
Widget build(BuildContext context) {
return Text(title ?? ""); //made changes
}
}

Since the title is not required means title can be null so fixed in above code

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 2/11
4/22/25, 11:34 AM Flutter Coding Assessment

2. Error Debugging (Stateful Widget)

Question:
The developer is trying to increment a counter when the button is clicked, but the UI is not
updating. What’s wrong?

<Code>
class CounterPage extends StatefulWidget {
@override
_CounterPageState createState() => _CounterPageState();
}

class _CounterPageState extends State<CounterPage> {


int count = 0;

void incrementCounter() {
count++;
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: Text('Count: $count')),
floatingActionButton: FloatingActionButton(
onPressed: incrementCounter,
child: Icon(Icons.add),
),
);
}
}
</Code>

Expected Skill: Understanding of state management in StatefulWidget.

void incrementCounter() {

setState(){
count++;
}
}
Now it fix the error , sestate rebuild the widget and update the state see above code

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 3/11
4/22/25, 11:34 AM Flutter Coding Assessment

3. Coding Challenge (List Filtering & Display)

Question:
Create a Flutter screen that takes a list of strings and displays only the strings that start with a
specific letter, say 'A'. The filtered list should be shown in a ListView.

Expected Skill: Lists, filtering, state management, and UI layout.

class MyWidget extends StatelessWidget {


final list = ["avinash,"aaina" , "appd","chandan"];
final filterList = [];

MyWidget(this.title);

void Filter(String searchQuery){


filterList=list;

filterList=filterList.nameOfMethod(name=>name).contains(searchQuery).tolist();

@override
Widget build(BuildContext context) {
return Sacffold(

body:
Flexible(

childer:[

FormTextField(
title:"Search here:",

onChange: (searchQuery){
Filter(searchQuery);
}
),

ListViewBuilder(){
itemcount:filterList.legth(),
(contenxt,index){
return Listtile(title:list[index]);
}
}

)
)

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 4/11
4/22/25, 11:34 AM Flutter Coding Assessment

}
}
</Code>

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 5/11
4/22/25, 11:34 AM Flutter Coding Assessment

4. Coding Challenge (Form + Validation)

Question:
Build a simple Flutter form with the following fields:

➡️Name (required)
➡️Email (must be a valid email)
➡️Age (must be numeric)
Add validation and show a success snackbar on form submission.

Expected Skill: Form handling, TextFormField, validators, and snackbar.

class FotmPage extends StatefulWidget {


@override
_FotmPage State createState() => _FotmPage State();
}

class _FotmPage State extends State<FotmPage > {

final formKey= GlobalKey();

final namecontorller = TextEditingController();


final agecontorller = TextEditingController();
final emailcontorller = TextEditingController();

void FormValidation(){

if(formKey.currentstate.validate){
snackbar(titele:"form is not valid");
}else{
snackbar(titele:"Form submit successfully");
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Form(
key: formKey,
Column(
childeren[
TextFormField(
validator:

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 6/11
4/22/25, 11:34 AM Flutter Coding Assessment

onchange:(value){
if(value.isEmpty ){
return "$value can not be empty";
}

return;

),

TextFormField(
validator:

onchange:(value){
if(value.isEmpty ){
return "$value can not be empty";
}

return;

),

TextFormField(
validator:

onchange:(value){
if(value.isEmpty ){
return "$value can not be empty";
}

return;

),

floatingActionButton: FloatingActionButton(
onPressed: FormValidation,
child: Icon(Icons.add),
),

);

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 7/11
4/22/25, 11:34 AM Flutter Coding Assessment

}
}

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 8/11
4/22/25, 11:34 AM Flutter Coding Assessment

5. Coding Challenge (API Integration)

Question:
Create a screen that fetches a list of users from a public API (e.g.,
https://jsonplaceholder.typicode.com/users) and displays their names in a list. Show a loading
indicator while data is being fetched and handle API failure gracefully.

Expected Skill: http package, async/await, error handling, list display.

class ApiCall extends StatefulWidget {


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

class _ApiCallState extends State<ApiCall> {

Future<dynamic> fetch() async{


final url = "https://jsonplaceholder.typicode.com/users";

try{

final response = await http.get(Uri.parse(url));

if(response ==200){
return jsonDecode(response.body);
}else{
throw("Something went wrong $response.statuscode")
}
}

}catch(e){
throw(e)
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child:
FutureBuilder(
future: fetch(),
(context,snapshot){

if(snapshot.waiting){
return CircularIndicator()
}else{
final data = snapshot.data;

return ListviewBuilder(
itemcount:data .legth()

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pKw… 9/11
4/22/25, 11:34 AM Flutter Coding Assessment

context,index){
return Listtile(
title: data[index]['name']
)
}
}

)
),

);
}
}

6. Conceptual (Short Answer)

Question:
What is the difference between Navigator.push and Navigator.pushReplacement? When would
you use each?

Expected Skill: Navigation and route management.

Navigator.push is used to push the user to screen on the top of the current screen while
Navigator.pushReplacement also push the screen but it replace the current screen with new screen
when we no need of the current screen use Navigator.pushReplacement and when we need the screen
like we need come back just after that use Navigator.push

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pK… 10/11
4/22/25, 11:34 AM Flutter Coding Assessment

7. Coding + Error Fix (Animations)

Question:
The below animation doesn’t work as expected. Fix the issue and describe what was wrong.

<Code>
class FadeInWidget extends StatefulWidget {
@override
_FadeInWidgetState createState() => _FadeInWidgetState();
}

class _FadeInWidgetState extends State<FadeInWidget> with SingleTickerProviderStateMixin {


AnimationController _controller;
Animation<double> _animation;

@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: Duration(seconds: 2));
_animation = Tween(begin: 0.0, end: 1.0).animate(_controller);
}

@override
Widget build(BuildContext context) {
return FadeTransition(
opacity: _animation,
child: Text('Hello!'),
);
}
}
</Code>

Expected Skill: Understanding animation lifecycle, init/start, and state management.

This content is neither created nor endorsed by Google.

Forms

https://docs.google.com/forms/d/1W6MqY3-48hjifAOg5JaPNekiGH59f7f97nz4AGlIFu0/edit#response=ACYDBNgahtmAB7UHG_Hz-D_y071pK… 11/11

You might also like