0% found this document useful (0 votes)
17 views4 pages

Flutter Viva QnA

bngvvn

Uploaded by

Shrenik Pittala
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)
17 views4 pages

Flutter Viva QnA

bngvvn

Uploaded by

Shrenik Pittala
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/ 4

Flutter Voce-Viva QnA

1. What is Flutter, and why is it used?


Ans) Flutter is Google’s open-source UI toolkit for building natively com-
piled apps (mobile, web, desktop) from a single codebase. It’s used because
it offers fast development (hot reload), expressive UI, and high perfor-
mance.
2. What programming language does Flutter use?
Ans) Flutter uses the Dart programming language, also developed by
Google.
3. What is the difference between Flutter and other frameworks
like React Native?
Ans) Flutter compiles to native ARM code and uses its own rendering
engine for consistent UI, while React Native uses native components and
relies on a JavaScript bridge for rendering.
4. What is a widget in Flutter?
Ans) A widget is a basic building block of the Flutter UI. Everything you
see on the screen—text, buttons, layouts—is a widget.
5. Explain the difference between StatelessWidget and StatefulWidget.
Ans) A StatelessWidget has no internal state and is immutable. A
StatefulWidget can change over time based on user interaction or other
factors, and it maintains a mutable state.
6. What is the role of the main() function in Flutter?
Ans) The main() function is the entry point of the app. It runs first and
usually calls runApp() to start the Flutter application.
7. How does hot reload work in Flutter?
Ans) Hot reload injects updated source code into the running Dart Virtual
Machine, letting you quickly see changes in the UI without restarting the
whole app.

8. How does Flutter handle asynchronous programming? Give an


example.
Ans) Flutter uses Dart’s async and await keywords with Futures or
Streams.

1
Future<String> fetchData() async {
return await Future.delayed(
Duration(seconds: 2),
() => "Data loaded"
);
}

9. What are the different types of animations in Flutter?


Ans) Common types include Tween animations (explicit), Hero anima-
tions (shared element), and Implicit animations (e.g., AnimatedContainer,
AnimatedOpacity).
10. How do you manage state?
Ans) State can be managed with setState() (local), InheritedWidget,
Provider, Riverpod, Bloc, or other state management solutions based on
app complexity.

11. What are keys in Flutter, and why are they important?
Ans) Keys help Flutter identify and preserve widget states when widgets
move or change order. They’re crucial for correctly handling lists, forms,
and animations.
12. Create a simple Flutter app that displays “Hello, World!” on
the screen.
Ans)

import ’package:flutter/material.dart’;

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

class MyApp extends StatelessWidget {


@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Text(’Hello, World!’),
),
),
);
}
}

13. Design a layout with a Column containing three Text widgets.


Ans)

Column(

2
children: [
Text(’First’),
Text(’Second’),
Text(’Third’),
],
)

14. Implement a TextField that updates a Text widget below it when


the input changes.
Ans)

class MyWidget extends StatefulWidget {


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

class _MyWidgetState extends State<MyWidget> {


String textValue = "";

@override
Widget build(BuildContext context) {
return Column(
children: [
TextField(
onChanged: (value) {
setState(() {
textValue = value;
});
},
),
Text(textValue),
],
);
}
}

15. Create a Container widget with rounded corners, a shadow, and


a gradient background.
Ans)

Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey,

3
blurRadius: 5,
offset: Offset(2, 2)
),
],
gradient: LinearGradient(
colors: [Colors.blue, Colors.purple],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
width: 200,
height: 100,
)

You might also like