Skip to content

Commit 06c6a54

Browse files
committed
qns: add interview questions from 81 up to 100
1 parent e10cf6e commit 06c6a54

File tree

40 files changed

+573
-0
lines changed

40 files changed

+573
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Can you communicate between isolates? Describe an Isolate?
3+
---
4+
5+
Yes, you can communicate between isolates in Dart using message passing via `SendPort` and `ReceivePort`. Isolates do not share memory, and each isolate has its own memory space and event loop. To communicate, one isolate sends messages to another through a `SendPort`, and the receiving isolate listens on a `ReceivePort`.
6+
7+
**Isolate:**
8+
An Isolate is a separate thread of execution in Dart that runs independently, using its own memory and event loop. It's useful for performing concurrent tasks without blocking the main isolate, which is critical for Flutter apps to keep the UI responsive.
9+
10+
```dart
11+
import 'dart:isolate';
12+
13+
void main() async {
14+
// Create a receive port to listen for messages from the isolate
15+
final receivePort = ReceivePort();
16+
17+
// Spawn an isolate and send the receive port's sendPort to it
18+
await Isolate.spawn(isolateFunction, receivePort.sendPort);
19+
20+
// Listen for messages from the isolate
21+
receivePort.listen((message) {
22+
print('Received message: $message');
23+
receivePort.close(); // Close the receive port when done
24+
});
25+
}
26+
27+
// Function to be executed by the isolate
28+
void isolateFunction(SendPort sendPort) {
29+
sendPort.send('Hello from the isolate!');
30+
}
31+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"slug": "can-you-communicate-between-isolates-describe-an-isolate",
3+
"rank": 90,
4+
"difficulty": "advanced"
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Can you describe how to implement internationalization in a flutter app?
3+
---
4+
5+
To implement internationalization (i18n) in a Flutter app:
6+
7+
- Include the `flutter_localizations` package in the `pubspec.yaml` file.
8+
- Set the `localizationsDelegates` and `supportedLocales` properties in the MaterialApp.
9+
- Use .arb files to store translations for different locales (e.g., app_en.arb for English, app_es.arb for Spanish).
10+
- Use the flutter `gen-l10n` tool to generate Dart localization classes from the .arb files.
11+
- Use the generated localization class (e.g., `AppLocalizations.of(context).<key>`) to access translated strings.
12+
- Test the app by switching locales in device settings and updating .arb files as needed.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"slug": "can-you-describe-how-to-implement-internationalization-in-a-flutter-app",
3+
"rank": 84,
4+
"difficulty": "advanced"
5+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Explain how you will deploy a Flutter app to the Google Play/App Store?
3+
---
4+
5+
To deploy a Flutter app to the Google Play Store or App Store, follow these steps while adhering to their respective guidelines on content, user privacy, and design:
6+
7+
**Deploying to Google Play Store:**
8+
- Google Play Developer Account: Create an account and set it up.
9+
- Generate a Signing Key: Sign your app for secure distribution.
10+
- Prepare App Configuration: Update build.gradle with package details and versioning.
11+
- Build the Release APK or AAB: Run flutter build apk or flutter build appbundle.
12+
- Upload and Submit: Submit the app via the Play Console, including screenshots and metadata.
13+
- Review and Publish: Wait for approval, then publish.
14+
15+
**Deploying to App Store:**
16+
- Apple Developer Account: Enroll and set up your account.
17+
- Provisioning Profile & Certificate: Use Xcode to create a signing certificate and provision your app.
18+
- Prepare App Configuration: Update your app's bundle ID and version.
19+
- Build the iOS Archive: Run flutter build ios and export the archive using Xcode.
20+
- Submit and Review: Upload the app via Xcode or Transporter, fill out metadata, and submit for review.
21+
- Publish: Once approved, your app goes live.
22+
23+
Ensure you test the app thoroughly and address any guidelines to streamline the approval process.
24+
- [Google Play Store Guildelines](https://play.google.com/console/about/guides/releasewithconfidence/)
25+
- [Apple App Review Guildelines](https://developer.apple.com/app-store/review/guidelines/)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"slug": "explain-how-you-will-deploy-a-flutter-app-to-the-google-playapp-store",
3+
"rank": 81,
4+
"difficulty": "advanced"
5+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Explain what a ticker is in flutter.
3+
---
4+
5+
In Flutter, a ticker is a mechanism that helps to drive animations. It provides a continuous stream of time, essentially ticking at a fixed interval (typically the frame rate). This enables the animation framework to update the UI at a consistent rate.
6+
7+
A `Ticker` is often used with `AnimationController`, which is responsible for controlling the animation's progress over time. The Ticker's job is to notify the animation controller every frame so that it can update the animation’s state, which in turn updates the UI.
8+
9+
```dart
10+
class MyAnimatedWidget extends StatefulWidget {
11+
@override
12+
_MyAnimatedWidgetState createState() => _MyAnimatedWidgetState();
13+
}
14+
15+
class _MyAnimatedWidgetState extends State<MyAnimatedWidget> with TickerProviderStateMixin {
16+
late Ticker _ticker;
17+
18+
@override
19+
void initState() {
20+
super.initState();
21+
_ticker = createTicker((elapsed) {
22+
print('Time elapsed: $elapsed');
23+
});
24+
_ticker.start(); // Starts the ticker
25+
}
26+
27+
@override
28+
void dispose() {
29+
_ticker.dispose(); // Clean up the ticker
30+
super.dispose();
31+
}
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return Container();
36+
}
37+
}
38+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"slug": "explain-what-a-ticker-is-in-flutter",
3+
"rank": 91,
4+
"difficulty": "intermediate"
5+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: How do mixins differ from interfaces in Dart?
3+
---
4+
5+
In Dart, mixins and interfaces serve different purposes:
6+
7+
**Mixins:** Allow a class to reuse code from multiple classes without using inheritance. Mixins are typically used to add functionality to a class. They are declared using the mixin keyword and can be applied to a class via the with keyword. A class can apply multiple mixins.
8+
9+
```dart
10+
mixin Walker {
11+
void walk() => print("Walking");
12+
}
13+
14+
class Person with Walker {
15+
// Person can now use the walk() method
16+
}
17+
```
18+
19+
**Interfaces:** Define a contract that a class must adhere to. In Dart, all classes implicitly act as interfaces. To implement an interface, a class uses the implements keyword. Unlike mixins, interfaces do not allow code reuse—they only define method signatures that must be implemented.
20+
21+
```dart
22+
class Animal {
23+
void eat();
24+
}
25+
26+
class Dog implements Animal {
27+
@override
28+
void eat() => print("Dog eating");
29+
}
30+
```
31+
32+
**Key Differences:**
33+
- Mixins provide code reuse; can be used with multiple classes.
34+
- Interfaces define required methods, but no code reuse. A class can implement multiple interfaces.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"slug": "how-do-mixins-differ-from-interfaces-in-dart",
3+
"rank": 100,
4+
"difficulty": "intermediate"
5+
}

0 commit comments

Comments
 (0)