You are on page 1of 9

Flutter Test (15 Questions)

 Theory
 Let’s Fill the Code!
 Fill & Draw to Code!

Theory
1. Flutter is based on? (2.5 Point)
a) JavaScript
b) Dart
c) C++
d) Python
2. What is the difference between StatefulWidget and StatelessWidget? (2.5 Point)
a) StatelessWidget is for complex UI, in other hands StatefulWidget is not
recommended for complex UI
b) StatefulWidget have their state created only once — therefore, the build method is
called only once as well. StatelessWidget have their state explicitly created, and it
can be modified during the lifetime of the widget.
c) StatelessWidget have their state created only once — therefore, the build method is
called only once as well. StatefulWidget have their state explicitly created, and it can
be modified during the lifetime of the widget.
d) None of them
3. What is NOT State Management in Flutter (2.5 Point)
a) BLoC
b) Redux
c) Retrofit
d) GetX
4. Is possible to nest a Scaffold on Flutter? (2.5 Point)
a) Yes
b) No
5. What is NOT part of the Flutter widget (2.5 Point)
a) SliverAppBar()
b) TextButton()
c) Button()
d) AnimatedContainer()
6. There is a text overflow below, choose the right widget to fill the blank space and then
the issue will be fixed. (Min 1 Answer). (2.5 Point)

 Flex
 Flexible
 Wrap
 Expanded

Question 7 & 8 - Assume that we have a class that called Recipes.dart:


class Recipes {
  String cheese;
  String bun;
  String meat;

  Recipes(this.cheese, this.bun, this.meat);

  String giveMeCheeseBurger() {
    return bun+cheese+meat;
  }
}

7. Please convert giveMeCheeseBurger() to a getter called cheeseBurger using the


Shorthand Fat-arrow Syntax! (5 Point)
Answer:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Assume that we receive response data from API :

8. Please add constructor to Serializing a JSON from API inside model class (Recipes.dart)
with Null-Aware Operator (5 Point)
Answer:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

Question 9 – Null Assertion


The code below will give you an error when running on Null-Safety version, let’s fix the code
by modify the code below and guess the output. (10 Point)
**IMPORTANT : Mark your answer with BOLD and GREEN color.
int? couldReturnNullButDoesnt() => -3;

  void main() {
    int? couldBeNullButIsnt = 1;
    List<int?> listThatCouldHoldNulls = [2, null, 4];

    int a = couldBeNullButIsnt;
    int b = listThatCouldHoldNulls.first;
    int c = couldReturnNullButDoesnt().abs();

    print('a is $a.');
    print('b is $b.');
    print('c is $c.');
  }
Answer:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Let’s Fill the Code!
Question 10 - (14 Answers) – (15 Point)

Image for Question 9


List<String> chars = ['A', 'B', 'C', 'D', 'E'];
double radius = 8.0;
double styling = 12.0;
@override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _______________(

        child: _______________(
          mainAxisAlignment: _______________,
          children: chars. _______________((_______________) => Container(
                    padding: EdgeInsets. _______________(_______________),
                    decoration: _______________(
                        color: Colors.red,
                        borderRadius: BorderRadius. ____________(________)),
                    child: Text(
                      _______________._______________,
                      style: _______________,
                    ),
                  )). _______________,
        ),
      ),
    );
  }
Question 11 - (17 Answers) - (15 Point)

Image for Question 10


List<String> languages = ['Dart', 'Java', 'C++', 'Python'];
double styling = 12.0;
List<_______________> colors = [Colors.red, Colors.orange];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _______________.builder(
        itemCount: _______________,
        _______________: (_______________) => Container(
          decoration: _______________ (
            gradient: _______________ (
              begin: _______________,
              end: _______________,
              colors: _______________,
            ),
          ),
          margin: EdgeInsets. _______________ (bottom: _______________),
          padding: EdgeInsets. _______________ (_______________),
          child: Center(
            child: Text(
              _______________._______________,
              style: _______________,
            ),
          ),
        ),
      ),
    );
  }
Question 12 - (11 Answers) - (10 Point)

Image for Question 11


List<____________________> navbarItems = [
    {'icon': Icons.home, 'label': 'Home'},
    {'icon': Icons.list, 'label': 'My Task'},
    {'icon': Icons.person, 'label': 'My Profile'},
  ];

@override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: _______________(
_______________: (index) => toDo(),

        _______________ : Colors.red,
        _______________ : Colors.grey,
        items: navbarItems
            .___________(
              (_______________) => _________________(
                icon: Icon(_______________),
                label: _______________,
              ),
            )._______________,
      ),
    );
  }
Fill & Draw from the Codes! – 13,14 and 15 – (25 Point)
Fill the blank space and then DRAW the result of the code below.
Question 13
var number = [12, 30, 56, 20, 45, 23];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Fizz Buzz'),
      ),
      body: Center(
        child: Column(
          children: number._____(
                (_____) => _____ % 3 == 0 && _____ % 5 == 0
                    ? Text('FizzBuzz')
                    : _____ % 3 == 0
                        ? Text('Fizz')
                        : _____ % 5 == 0
                            ? Text("Buzz")
                            : Text('$_____'),
              ).______,
        ),
      ),
    );
  }

DRAW:
Question 14

DRAW:
Question 15

DRAW:

You might also like