Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

book: init flutter snippets #682

Merged
merged 1 commit into from
Dec 18, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
distribution: "temurin"
java-version: 17

# Required for dart/flutter snippets
- uses: subosito/flutter-action@v2

- name: Check
run: just check-book

Expand Down
7 changes: 7 additions & 0 deletions book/snippets/flutter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
packages/
.flutter-version
.flutter-plugins
.flutter-plugins-dependencies
30 changes: 30 additions & 0 deletions book/snippets/flutter/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:
- packages/**

# 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
5 changes: 5 additions & 0 deletions book/snippets/flutter/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env just --justfile

test:
flutter pub get
dart analyze --fatal-infos
25 changes: 25 additions & 0 deletions book/snippets/flutter/lib/hello.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ANCHOR: full

import 'package:nostr_sdk/nostr_sdk.dart';

Future<void> hello() async {
// ANCHOR: client
Keys keys = Keys.generate();
NostrSigner signer = NostrSigner.keys(keys: keys);
Client client = Client.builder().signer(signer: signer).build();
// ANCHOR_END: client

// ANCHOR: connect
await client.addRelay(url: "wss://relay.damus.io");
await client.connect();
// ANCHOR_END: connect

// ANCHOR: publish
// TODO
// ANCHOR_END: publish

// ANCHOR: output
// TODO
// ANCHOR_END: output
}
// ANCHOR_END: full
Loading
Loading