diff --git a/README.md b/README.md index 77ae3aec..cd5c0fbf 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ StreamBuilder( builder: (context, snapshot) { final rustSignal = snapshot.data; if (rustSignal == null) { - return Text("Nothing received yet"); + return Text('Nothing received yet'); } final myMessage = rustSignal.message; return Text(myMessage.currentNumber.toString()); diff --git a/documentation/docs/frequently-asked-questions.md b/documentation/docs/frequently-asked-questions.md index 83286aad..d0fc281b 100644 --- a/documentation/docs/frequently-asked-questions.md +++ b/documentation/docs/frequently-asked-questions.md @@ -315,7 +315,7 @@ In this case, you can specify a path that points to the compiled Rust library. S import './messages/exports.dart'; async void main() { - await initializeRust(compiledLibPath: "/path/to/library/libhub.so"); + await initializeRust(compiledLibPath: '/path/to/library/libhub.so'); } ``` diff --git a/documentation/docs/tutorial.md b/documentation/docs/tutorial.md index 121d991e..ecb899df 100644 --- a/documentation/docs/tutorial.md +++ b/documentation/docs/tutorial.md @@ -49,7 +49,7 @@ child: Column( inputString: 'Zero-cost abstraction', ).sendSignalToRust(); // GENERATED }, - child: Text("Send a Signal from Dart to Rust"), + child: Text('Send a Signal from Dart to Rust'), ), ] ) @@ -154,7 +154,7 @@ children: [ builder: (context, snapshot) { final rustSignal = snapshot.data; if (rustSignal == null) { - return Text("Nothing received yet"); + return Text('Nothing received yet'); } final myAmazingNumber = rustSignal.message; final currentNumber = myAmazingNumber.currentNumber; diff --git a/flutter_package/README.md b/flutter_package/README.md index 77ae3aec..cd5c0fbf 100644 --- a/flutter_package/README.md +++ b/flutter_package/README.md @@ -45,7 +45,7 @@ StreamBuilder( builder: (context, snapshot) { final rustSignal = snapshot.data; if (rustSignal == null) { - return Text("Nothing received yet"); + return Text('Nothing received yet'); } final myMessage = rustSignal.message; return Text(myMessage.currentNumber.toString()); diff --git a/flutter_package/analysis_options.yaml b/flutter_package/analysis_options.yaml index c36c2c5d..937707a6 100644 --- a/flutter_package/analysis_options.yaml +++ b/flutter_package/analysis_options.yaml @@ -1 +1,5 @@ include: package:lints/core.yaml + +linter: + rules: + - prefer_single_quotes diff --git a/flutter_package/bin/rinf.dart b/flutter_package/bin/rinf.dart index 8db92fa5..920b1a21 100644 --- a/flutter_package/bin/rinf.dart +++ b/flutter_package/bin/rinf.dart @@ -5,51 +5,51 @@ import 'src/internet.dart'; Future main(List args) async { if (args.isEmpty) { - print("No operation is provided."); - print("Use `rinf --help` to see all available operations."); + print('No operation is provided.'); + print('Use `rinf --help` to see all available operations.'); return; } - final rinfConfig = await loadVerifiedRinfConfig("pubspec.yaml"); + final rinfConfig = await loadVerifiedRinfConfig('pubspec.yaml'); await checkConnectivity(); switch (args[0]) { - case "config": + case 'config': print(rinfConfig); break; - case "template": + case 'template': await applyRustTemplate(messageConfig: rinfConfig.message); break; - case "message": - if (args.contains("--watch") || args.contains("-w")) { + case 'message': + if (args.contains('--watch') || args.contains('-w')) { await watchAndGenerateMessageCode(messageConfig: rinfConfig.message); } else { await generateMessageCode(messageConfig: rinfConfig.message); } break; - case "wasm": - if (args.contains("--release") || args.contains("-r")) { + case 'wasm': + if (args.contains('--release') || args.contains('-r')) { await buildWebassembly(isReleaseMode: true); } else { await buildWebassembly(); } break; - case "--help": - case "-h": - print("Usage: rinf [arguments]"); - print("Arguments:"); - print(" -h, --help Shows this usage information."); - print(" config Shows current Rinf configuration" - "\n resolved from `pubspec.yaml`" - "\n with defaults applied."); - print(" template Applies Rust template" - "\n to current Flutter project."); - print(" message Generates message code from `.proto` files."); - print(" -w, --watch Continuously watches `.proto` files."); - print(" wasm Builds webassembly module."); - print(" -r, --release Builds in release mode."); + case '--help': + case '-h': + print('Usage: rinf [arguments]'); + print('Arguments:'); + print(' -h, --help Shows this usage information.'); + print(' config Shows current Rinf configuration' + '\n resolved from `pubspec.yaml`' + '\n with defaults applied.'); + print(' template Applies Rust template' + '\n to current Flutter project.'); + print(' message Generates message code from `.proto` files.'); + print(' -w, --watch Continuously watches `.proto` files.'); + print(' wasm Builds webassembly module.'); + print(' -r, --release Builds in release mode.'); default: - print("No such operation is available."); - print("Use `rinf --help` to see all available operations."); + print('No such operation is available.'); + print('Use `rinf --help` to see all available operations.'); } } diff --git a/flutter_package/bin/src/common.dart b/flutter_package/bin/src/common.dart index fec58a8f..3bbe5171 100644 --- a/flutter_package/bin/src/common.dart +++ b/flutter_package/bin/src/common.dart @@ -1,6 +1,6 @@ extension UriJoin on Uri { Uri join(String path) { - if (path.isEmpty || path == "/") { + if (path.isEmpty || path == '/') { // By default, `resolve` method returns root directory // when provided string is empty or a slash. // We need to override this. diff --git a/flutter_package/bin/src/config.dart b/flutter_package/bin/src/config.dart index 2992e5af..5aa67660 100644 --- a/flutter_package/bin/src/config.dart +++ b/flutter_package/bin/src/config.dart @@ -28,7 +28,7 @@ class RinfConfigMessage { if (!MESSAGE_CONFIG_KEYS.contains(key)) { throw Exception( "Unknown key '$key' in rinf message configuration.\n" - "Available keys are: $MESSAGE_CONFIG_KEYS", + 'Available keys are: $MESSAGE_CONFIG_KEYS', ); } } @@ -49,14 +49,14 @@ class RinfConfigMessage { $KEY_RUST_SERDE: $rustSerde'''; } - static const KEY_INPUT_DIR = "input_dir"; - static const KEY_RUST_OUTPUT_DIR = "rust_output_dir"; - static const KEY_DART_OUTPUT_DIR = "dart_output_dir"; - static const KEY_RUST_SERDE = "rust_serde"; + static const KEY_INPUT_DIR = 'input_dir'; + static const KEY_RUST_OUTPUT_DIR = 'rust_output_dir'; + static const KEY_DART_OUTPUT_DIR = 'dart_output_dir'; + static const KEY_RUST_SERDE = 'rust_serde'; - static const DEFAULT_INPUT_DIR = "messages/"; - static const DEFAULT_RUST_OUTPUT_DIR = "native/hub/src/messages/"; - static const DEFAULT_DART_OUTPUT_DIR = "lib/messages/"; + static const DEFAULT_INPUT_DIR = 'messages/'; + static const DEFAULT_RUST_OUTPUT_DIR = 'native/hub/src/messages/'; + static const DEFAULT_DART_OUTPUT_DIR = 'lib/messages/'; static const DEFAULT_RUST_SERDE = false; static const MESSAGE_CONFIG_KEYS = [ @@ -81,7 +81,7 @@ class RinfConfig { if (!RINF_CONFIG_KEYS.contains(key)) { throw Exception( "Unknown key '$key' in rinf configuration.\n" - "Available keys are: $RINF_CONFIG_KEYS", + 'Available keys are: $RINF_CONFIG_KEYS', ); } } @@ -100,7 +100,7 @@ rinf: $message'''; } - static const KEY_MESSAGE = "message"; + static const KEY_MESSAGE = 'message'; static const RINF_CONFIG_KEYS = [KEY_MESSAGE]; } diff --git a/flutter_package/bin/src/helpers.dart b/flutter_package/bin/src/helpers.dart index 04b07ace..25943482 100644 --- a/flutter_package/bin/src/helpers.dart +++ b/flutter_package/bin/src/helpers.dart @@ -25,7 +25,7 @@ Future applyRustTemplate({ final packagePath = package.root; // Check if current folder is a Flutter app project. - final specFile = File.fromUri(flutterProjectPath.join("pubspec.yaml")); + final specFile = File.fromUri(flutterProjectPath.join('pubspec.yaml')); final isFlutterProject = await specFile.exists(); if (!isFlutterProject) { print("This folder doesn't look like a Flutter project."); @@ -33,17 +33,17 @@ Future applyRustTemplate({ } final pubspec = loadYaml(await specFile.readAsString()); final String? publishTo = pubspec['publish_to']; - if (publishTo != "none") { - print("Flutter package development is not supported by Rinf."); + if (publishTo != 'none') { + print('Flutter package development is not supported by Rinf.'); return; } // Copy basic folders needed for Rust to work - final templateSource = packagePath.join("template/native/"); - final templateDestination = flutterProjectPath.join("native/"); + final templateSource = packagePath.join('template/native/'); + final templateDestination = flutterProjectPath.join('native/'); await copyDirectory(templateSource, templateDestination); - final messagesSource = packagePath.join("template/messages/"); - final messagesDestination = flutterProjectPath.join("messages/"); + final messagesSource = packagePath.join('template/messages/'); + final messagesDestination = flutterProjectPath.join('messages/'); await copyDirectory(messagesSource, messagesDestination); // Create workspace `Cargo.toml` @@ -93,7 +93,7 @@ resolver = "2" var readmeSplitted = readmeContent.split('\n\n'); readmeSplitted = readmeSplitted.map((s) => s.trim()).toList(); if (!readmeContent.contains(guideSectionTitle)) { - final text = ''' + final text = """ $guideSectionTitle This project leverages Flutter for GUI and Rust for the backend logic, @@ -135,7 +135,7 @@ flutter run For detailed instructions on writing Rust and Flutter together, please refer to Rinf's [documentation](https://rinf.cunarist.com). -'''; +"""; readmeSplitted.add(text); } await readmeFile.writeAsString(readmeSplitted.join('\n\n') + '\n'); @@ -144,12 +144,12 @@ please refer to Rinf's [documentation](https://rinf.cunarist.com). await Process.run('dart', ['pub', 'add', 'protobuf']); // Modify `./lib/main.dart` - final mainFile = File.fromUri(flutterProjectPath.join("lib/main.dart")); + final mainFile = File.fromUri(flutterProjectPath.join('lib/main.dart')); if (await mainFile.exists()) { await Process.run('dart', ['format', './lib/main.dart']); var mainText = await mainFile.readAsString(); if (!mainText.contains('messages/exports.dart')) { - final lines = mainText.split("\n"); + final lines = mainText.split('\n'); final lastImportIndex = lines.lastIndexWhere( (line) => line.startsWith('import '), ); @@ -161,7 +161,7 @@ please refer to Rinf's [documentation](https://rinf.cunarist.com). lastImportIndex + 2, "import './messages/exports.dart';", ); - mainText = lines.join("\n"); + mainText = lines.join('\n'); } if (!mainText.contains('initializeRust(assignRustSignal)')) { mainText = mainText.replaceFirst( @@ -179,7 +179,7 @@ please refer to Rinf's [documentation](https://rinf.cunarist.com). await generateMessageCode(silent: true, messageConfig: messageConfig); - print("🎉 Rust template is now ready! 🎉"); + print('🎉 Rust template is now ready! 🎉'); } Future copyDirectory(Uri source, Uri destination) async { @@ -204,38 +204,38 @@ Future copyDirectory(Uri source, Uri destination) async { Future buildWebassembly({bool isReleaseMode = false}) async { // Ensure Rust toolchain. if (isInternetConnected) { - print("Ensuring Rust toolchain for the web." + - "\nThis is done by installing it globally on the system."); + print('Ensuring Rust toolchain for the web.' + + '\nThis is done by installing it globally on the system.'); final processResults = []; - processResults.add(await Process.run("rustup", [ - "toolchain", - "install", - "nightly", + processResults.add(await Process.run('rustup', [ + 'toolchain', + 'install', + 'nightly', ])); - processResults.add(await Process.run("rustup", [ - "+nightly", - "component", - "add", - "rust-src", + processResults.add(await Process.run('rustup', [ + '+nightly', + 'component', + 'add', + 'rust-src', ])); - processResults.add(await Process.run("rustup", [ - "+nightly", - "target", - "add", - "wasm32-unknown-unknown", + processResults.add(await Process.run('rustup', [ + '+nightly', + 'target', + 'add', + 'wasm32-unknown-unknown', ])); // For actual compilation - processResults.add(await Process.run("rustup", [ - "target", - "add", - "wasm32-unknown-unknown", + processResults.add(await Process.run('rustup', [ + 'target', + 'add', + 'wasm32-unknown-unknown', ])); // For Rust-analyzer - processResults.add(await Process.run("cargo", [ - "install", - "wasm-pack", + processResults.add(await Process.run('cargo', [ + 'install', + 'wasm-pack', ])); - processResults.add(await Process.run("cargo", [ - "install", - "wasm-bindgen-cli", + processResults.add(await Process.run('cargo', [ + 'install', + 'wasm-bindgen-cli', ])); processResults.forEach((processResult) { if (processResult.exitCode != 0) { @@ -244,7 +244,7 @@ Future buildWebassembly({bool isReleaseMode = false}) async { } }); } else { - print("Skipping ensurement of Rust toolchain for the web."); + print('Skipping ensurement of Rust toolchain for the web.'); } // Prepare the webassembly output path. @@ -253,7 +253,7 @@ Future buildWebassembly({bool isReleaseMode = false}) async { final outputPath = flutterProjectPath.uri.join(subPath); // Build the webassembly module. - print("Compiling Rust with `wasm-pack` to `web` target..."); + print('Compiling Rust with `wasm-pack` to `web` target...'); final compileCommand = await Process.run( 'wasm-pack', [ @@ -278,19 +278,19 @@ Future buildWebassembly({bool isReleaseMode = false}) async { print(compileCommand.stderr.toString().trim()); throw Exception('Unable to compile Rust into webassembly'); } - print("Saved `.wasm` and `.js` files to `$subPath`."); + print('Saved `.wasm` and `.js` files to `$subPath`.'); // Guide the developer how to run Flutter web server with web headers. - print("To run the Flutter web server, use:"); + print('To run the Flutter web server, use:'); final commandLineDivider = await getCommandLineDivider(); final commandLines = [ 'flutter run', '--web-header=Cross-Origin-Opener-Policy=same-origin', '--web-header=Cross-Origin-Embedder-Policy=require-corp' ]; - print(commandLines.join(" ${commandLineDivider}\n")); + print(commandLines.join(' ${commandLineDivider}\n')); - print("🎉 Webassembly module is now ready! 🎉"); + print('🎉 Webassembly module is now ready! 🎉'); } Future getCommandLineDivider({bool isReleaseMode = false}) async { @@ -298,15 +298,15 @@ Future getCommandLineDivider({bool isReleaseMode = false}) async { // Windows environment, check further for PowerShell or CMD if (Platform.environment['SHELL'] == null) { // Likely PowerShell environment - return "`"; + return '`'; // // Likely Command Prompt (cmd.exe) // return "^"; } else { // Bash or some other shell - return "\\"; + return '\\'; } } else { // Bash or some other shell - return "\\"; + return '\\'; } } diff --git a/flutter_package/bin/src/message.dart b/flutter_package/bin/src/message.dart index f37053c6..553c5c2f 100644 --- a/flutter_package/bin/src/message.dart +++ b/flutter_package/bin/src/message.dart @@ -71,7 +71,7 @@ Future generateMessageCode({ final packagePattern = r'^package\s+[a-zA-Z_][a-zA-Z0-9_\.]*\s*[^=];$'; if (RegExp(packagePattern).hasMatch(line.trim())) { continue; - } else if (line.trim().startsWith("syntax")) { + } else if (line.trim().startsWith('syntax')) { continue; } else { outputLines.add(line); @@ -86,8 +86,8 @@ Future generateMessageCode({ // Generate Rust message files. if (isInternetConnected) { if (!silent) { - print("Ensuring `protoc-gen-prost` for Rust." + - "\nThis is done by installing it globally on the system."); + print('Ensuring `protoc-gen-prost` for Rust.' + + '\nThis is done by installing it globally on the system.'); } final cargoInstallCommand = await Process.run('cargo', [ 'install', @@ -100,7 +100,7 @@ Future generateMessageCode({ } } else { if (!silent) { - print("Skipping ensurement of `protoc-gen-prost` for Rust."); + print('Skipping ensurement of `protoc-gen-prost` for Rust.'); } } for (final entry in resourcesInFolders.entries) { @@ -148,13 +148,13 @@ Future generateMessageCode({ if (otherSubPath != subPath && otherSubPath.contains(subPath)) { final subPathSplitted = subPath .trim() - .split("/") + .split('/') .where( (element) => element.isNotEmpty, ) .toList(); final otherSubPathSplitted = otherSubPath - .split("/") + .split('/') .where( (element) => element.isNotEmpty, ) @@ -178,9 +178,9 @@ Future generateMessageCode({ modRsLines.add('pub use $childName::*;'); } } - if (subPath == "/") { - modRsLines.add("pub mod generated;"); - modRsLines.add("pub use generated::*;"); + if (subPath == '/') { + modRsLines.add('pub mod generated;'); + modRsLines.add('pub use generated::*;'); } final modRsContent = modRsLines.join('\n'); await File.fromUri(rustOutputPath.join(subPath).join('mod.rs')) @@ -190,8 +190,8 @@ Future generateMessageCode({ // Generate Dart message files. if (isInternetConnected) { if (!silent) { - print("Ensuring `protoc_plugin` for Dart." + - "\nThis is done by installing it globally on the system."); + print('Ensuring `protoc_plugin` for Dart.' + + '\nThis is done by installing it globally on the system.'); } final pubGlobalActivateCommand = await Process.run('dart', [ 'pub', @@ -205,7 +205,7 @@ Future generateMessageCode({ } } else { if (!silent) { - print("Skipping ensurement of `protoc_plugin` for Dart."); + print('Skipping ensurement of `protoc_plugin` for Dart.'); } } for (final entry in resourcesInFolders.entries) { @@ -241,8 +241,8 @@ Future generateMessageCode({ exportsDartLines.add("export './generated.dart';"); for (final entry in resourcesInFolders.entries) { var subPath = entry.key; - if (subPath == "/") { - subPath = ""; + if (subPath == '/') { + subPath = ''; } final resourceNames = entry.value; for (final resourceName in resourceNames) { @@ -271,17 +271,17 @@ Future generateMessageCode({ if (!dartContent.contains("import 'dart:typed_data'")) { await insertTextToFile( dartPath, - ''' + """ // ignore_for_file: invalid_language_version_override import 'dart:async'; import 'dart:typed_data'; import 'package:rinf/rinf.dart'; -''', +""", atFront: true, ); } - if (!rustContent.contains("use std::sync")) { + if (!rustContent.contains('use std::sync')) { await insertTextToFile( rustPath, ''' @@ -365,7 +365,7 @@ extension ${messageName}Ext on $messageName{ static final rustSignalStream = ${camelName}Controller.stream.asBroadcastStream(); ''', - after: "class $messageName extends \$pb.GeneratedMessage {", + after: 'class $messageName extends \$pb.GeneratedMessage {', ); await insertTextToFile( dartPath, @@ -417,7 +417,7 @@ impl ${normalizePascal(messageName)} { } // Get ready to handle received signals in Rust. - var rustReceiveScript = ""; + var rustReceiveScript = ''; rustReceiveScript += ''' #![allow(unused_imports)] #![allow(unused_mut)] @@ -452,8 +452,8 @@ pub fn assign_dart_signal( markType == MarkType.dartSignalBinary) { final messageName = markedMessage.name; final snakeName = pascalToSnake(messageName); - var modulePath = subpath.replaceAll("/", "::"); - modulePath = modulePath == "::" ? "" : modulePath; + var modulePath = subpath.replaceAll('/', '::'); + modulePath = modulePath == '::' ? '' : modulePath; rustReceiveScript += ''' new_hash_map.insert( ${markedMessage.id}, @@ -490,15 +490,15 @@ new_hash_map.insert( .writeAsString(rustReceiveScript); // Get ready to handle received signals in Dart. - var dartReceiveScript = ""; - dartReceiveScript += ''' + var dartReceiveScript = ''; + dartReceiveScript += """ // ignore_for_file: unused_import import 'dart:typed_data'; import 'package:rinf/rinf.dart'; final rustSignalHandlers = { -'''; +"""; for (final entry in markedMessagesAll.entries) { final subpath = entry.key; final files = entry.value; @@ -511,13 +511,13 @@ final rustSignalHandlers = { markType == MarkType.rustSignalBinary) { final messageName = markedMessage.name; final camelName = pascalToCamel(messageName); - final importPath = subpath == "/" + final importPath = subpath == '/' ? '$filename.pb.dart' : '$subpath$filename.pb.dart'; if (!dartReceiveScript.contains(importPath)) { - dartReceiveScript = ''' + dartReceiveScript = """ import './$importPath' as $filename; -''' + +""" + dartReceiveScript; } dartReceiveScript += ''' @@ -546,14 +546,14 @@ void assignRustSignal(int messageId, Uint8List messageBytes, Uint8List binary) { // Notify that it's done if (!silent) { - print("🎉 Message code in Dart and Rust is now ready! 🎉"); + print('🎉 Message code in Dart and Rust is now ready! 🎉'); } } Future watchAndGenerateMessageCode( {required RinfConfigMessage messageConfig}) async { final currentDirectory = Directory.current; - final messagesPath = join(currentDirectory.path, "messages"); + final messagesPath = join(currentDirectory.path, 'messages'); final messagesDirectory = Directory(messagesPath); // Listen to keystrokes in the CLI. @@ -572,14 +572,14 @@ Future watchAndGenerateMessageCode( // Watch `.proto` files. final watcher = PollingDirectoryWatcher(messagesDirectory.path); var generated = true; - print("Watching `.proto` files..."); - print("Press `q` to stop watching."); + print('Watching `.proto` files...'); + print('Press `q` to stop watching.'); watcher.events.listen((event) { - if (event.path.endsWith(".proto") && generated) { + if (event.path.endsWith('.proto') && generated) { var eventType = event.type.toString(); eventType = eventType[0].toUpperCase() + eventType.substring(1); final fileRelativePath = relative(event.path, from: messagesPath); - print("$eventType: $fileRelativePath"); + print('$eventType: $fileRelativePath'); generated = false; } }); @@ -591,7 +591,7 @@ Future watchAndGenerateMessageCode( if (!generated) { try { await generateMessageCode(silent: true, messageConfig: messageConfig); - print("Message code generated."); + print('Message code generated.'); } catch (error) { // When message code generation has failed } @@ -624,7 +624,7 @@ Future collectProtoFiles( } } var subPath = directory.path.replaceFirst(rootDirectory.path, ''); - subPath = subPath.replaceAll("\\", "/"); // For Windows + subPath = subPath.replaceAll('\\', '/'); // For Windows subPath = '$subPath/'; // Indicate that it's a folder, not a file resourcesInFolders[subPath] = resources; } @@ -692,11 +692,11 @@ Future>>> analyzeMarkedMessages( ); final content = await protoFile.readAsString(); final regExp = RegExp(r'{[^}]*}'); - final attrExp = RegExp(r"(?<=\[RINF:RUST-ATTRIBUTE\().*(?=\)\])"); + final attrExp = RegExp(r'(?<=\[RINF:RUST-ATTRIBUTE\().*(?=\)\])'); // Remove all { ... } blocks from the string final contentWithoutBlocks = content.replaceAll(regExp, ';'); - final statements = contentWithoutBlocks.split(";"); + final statements = contentWithoutBlocks.split(';'); for (final statementRaw in statements) { final statement = statementRaw.trim(); // To find "}\n\n// [RINF:RUST-SIGNAL]", @@ -705,8 +705,8 @@ Future>>> analyzeMarkedMessages( final lines = statement.split('\n'); for (final line in lines) { final trimmed = line.trim(); - if (trimmed.startsWith("message")) { - messageName = trimmed.replaceFirst("message", "").trim(); + if (trimmed.startsWith('message')) { + messageName = trimmed.replaceFirst('message', '').trim(); } } if (messageName == null) { @@ -714,13 +714,13 @@ Future>>> analyzeMarkedMessages( continue; } MarkType? markType = null; - if (statement.contains("[RINF:DART-SIGNAL]")) { + if (statement.contains('[RINF:DART-SIGNAL]')) { markType = MarkType.dartSignal; - } else if (statement.contains("[RINF:DART-SIGNAL-BINARY]")) { + } else if (statement.contains('[RINF:DART-SIGNAL-BINARY]')) { markType = MarkType.dartSignalBinary; - } else if (statement.contains("[RINF:RUST-SIGNAL]")) { + } else if (statement.contains('[RINF:RUST-SIGNAL]')) { markType = MarkType.rustSignal; - } else if (statement.contains("[RINF:RUST-SIGNAL-BINARY]")) { + } else if (statement.contains('[RINF:RUST-SIGNAL-BINARY]')) { markType = MarkType.rustSignalBinary; } @@ -780,14 +780,14 @@ String snakeToCamel(String input) { /// Converts a string `HeLLLLLLLo` to `HeLlllllLo`, /// just like `protoc-gen-prost` does. String normalizePascal(String input) { - var upperStreak = ""; - var result = ""; + var upperStreak = ''; + var result = ''; for (final character in input.split('')) { if (character.toUpperCase() == character) { upperStreak += character; } else { final fixedUpperStreak = lowerBetween(upperStreak); - upperStreak = ""; + upperStreak = ''; result += fixedUpperStreak; result += character; } diff --git a/flutter_package/example/lib/main.dart b/flutter_package/example/lib/main.dart index d84017e6..a5ea5dee 100644 --- a/flutter_package/example/lib/main.dart +++ b/flutter_package/example/lib/main.dart @@ -65,7 +65,7 @@ class MyHomePage extends StatelessWidget { // The `sendSignalToRust` method is generated // from a marked Protobuf message. SampleNumberInput( - letter: "HELLO FROM DART!", + letter: 'HELLO FROM DART!', dummyOne: 25, dummyTwo: SampleSchema( sampleFieldOne: true, diff --git a/flutter_package/lib/src/load_web.dart b/flutter_package/lib/src/load_web.dart index a339834a..3b7fd41f 100644 --- a/flutter_package/lib/src/load_web.dart +++ b/flutter_package/lib/src/load_web.dart @@ -9,7 +9,7 @@ String? jsLibPath; // When Dart performs hot restart, // the `rinf` object is already defined // as a global JavaScript variable. -final wasAlreadyLoaded = js.context.hasProperty("rinf"); +final wasAlreadyLoaded = js.context.hasProperty('rinf'); void setJsLibPath(String path) { jsLibPath = path; @@ -29,11 +29,11 @@ Future loadJsFile() async { final baseHref = Uri.base; // Use the default JavaScript path unless provided. - final path = jsLibPath ?? "pkg/hub.js"; + final path = jsLibPath ?? 'pkg/hub.js'; final fullUrl = baseHref.resolve(path); final scriptElement = ScriptElement(); - scriptElement.type = "module"; + scriptElement.type = 'module'; scriptElement.innerHtml = ''' import init, * as wasmBindings from "$fullUrl"; await init(); diff --git a/rust_crate/README.md b/rust_crate/README.md index 77ae3aec..cd5c0fbf 100644 --- a/rust_crate/README.md +++ b/rust_crate/README.md @@ -45,7 +45,7 @@ StreamBuilder( builder: (context, snapshot) { final rustSignal = snapshot.data; if (rustSignal == null) { - return Text("Nothing received yet"); + return Text('Nothing received yet'); } final myMessage = rustSignal.message; return Text(myMessage.currentNumber.toString());