Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/gen_content.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Generate Contents

on:
pull_request:
branches: ["main"]
push:
branches: ["main"]

jobs:
gen-content:
runs-on: ubuntu-latest
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1

- name: 📦 Install Dependencies
run: dart pub get --no-example

- name: ⚙️ Run Scripts
run: dart run

- name: Commit Changes (if required)
run: |
if ! git diff --quiet README.md; then
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions [Bot]"
git add README.md
git commit -m "[auto] generate readme contents"
git push
echo "[info] README Contents updated and committed."
else
echo "[info] No changes to README Contents."
fi
working-directory: ${{ github.workspace }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
1,596 changes: 1,265 additions & 331 deletions README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions __template__/en-US.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: TODO_REPLACE_TITLE
---

TODO_REPLACE_BODY

## Further Reading

- [Foo](#foo)
- [Bar](#bar)
5 changes: 5 additions & 0 deletions __template__/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"slug": "question-slug",
"rank": 999,
"difficulty": "easy"
}
30 changes: 30 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
6 changes: 6 additions & 0 deletions bin/flutter_interview_questions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:flutter_interview_questions/flutter_interview_questions.dart' as flutter_interview_questions;

Future<void> main(List<String> arguments) async {
final generator = flutter_interview_questions.QuestionGenerator();
await generator.generateReadmeContents();
}
3 changes: 3 additions & 0 deletions lib/flutter_interview_questions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'src/models/models.dart';
export 'src/question_generator.dart';
export 'src/utils.dart';
3 changes: 3 additions & 0 deletions lib/src/models/models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'question_formatter.dart';
export 'question_item.dart';
export 'question_metadata.dart';
20 changes: 20 additions & 0 deletions lib/src/models/question_formatter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// {@template question_formatter}
/// A formatter class that represents a structured question with a title and content.
///
/// This class is used to store and format questions, where:
/// - [title] is the heading of the question.
/// - [content] is the main body or answer of the question.
/// {@endtemplate}
class QuestionFormatter {
/// {@macro question_formatter}
const QuestionFormatter({required this.title, required this.content});

/// The title or heading of the question.
final String title;

/// The detailed content or answer of the question.
final String content;

@override
String toString() => 'QuestionFormatter(title: $title, content: $content)';
}
18 changes: 18 additions & 0 deletions lib/src/models/question_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter_interview_questions/flutter_interview_questions.dart';

/// {@template question_item}
/// Represents a structured question item with metadata and formatted content.
/// {@endtemplate}
class QuestionItem {
/// {@macro question_item}
const QuestionItem({required this.metadata, required this.formatter});

/// Metadata associated with the question
final QuestionMetadata metadata;

/// Formatted content of the question, including its title and body.
final QuestionFormatter formatter;

@override
String toString() => 'QuestionItem(metadata: $metadata, formatter: $formatter)';
}
68 changes: 68 additions & 0 deletions lib/src/models/question_metadata.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/// {@template question_metadata}
/// A model representing the metadata for an interview question.
/// {@endtemplate}
class QuestionMetadata {
/// {@macro question_metadata}
const QuestionMetadata({
required this.slug,
required this.difficulty,
required this.rank,
});

/// Converts a Map to a [QuestionMetadata].
factory QuestionMetadata.fromJson(Map<String, dynamic> json) {
return QuestionMetadata(
slug: json['slug'],
difficulty: QuestionDifficulty.values.byName(json['difficulty']),
rank: json['rank'],
);
}

/// An identifier for the question, typically a slugified version of the title.
final String slug;

/// The difficulty level of the question (easy, intermediate, or advanced).
final QuestionDifficulty difficulty;

/// A numerical value determining the position of the question in the list.
final int rank;

@override
String toString() {
return 'QuestionMetadata(slug: $slug, difficulty: ${difficulty.name}, rank: $rank)';
}
}

/// Defines the difficulty levels for interview questions.
///
/// - [easy]: Suitable for beginners or fundamental concepts.
/// - [intermediate]: Requires a moderate understanding of Flutter.
/// - [advanced]: Covers complex or in-depth Flutter topics.
enum QuestionDifficulty {
/// Questions that are uitable for beginners or fundamental concepts.
easy,

/// Question that equires a moderate understanding of Flutter.
intermediate,

// Question that overs complex or in-depth Flutter topics.
advanced,
}

/// Extension on [QuestionDifficulty].
extension QuestionDifficultyExtension on QuestionDifficulty {
/// Whether the question difficulty is easy.
bool get isEasy {
return this == QuestionDifficulty.easy;
}

/// Whether the question difficulty is intermediate.
bool get isIntermediate {
return this == QuestionDifficulty.intermediate;
}

/// Whether the question difficulty is advanced.
bool get isAdvanced {
return this == QuestionDifficulty.advanced;
}
}
Loading