Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>lazy JackNew to Visual Studio Code? Get it now.

lazy Jack

jackFan

|
7 installs
| (0) | Free
lets go
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Feature

  • Snippets Menu
  • Right click Menu

Convert selected json to freezed code

  • Right click Menu => @freezed json to freezed
  • auto run build_runner

Before

Before

After

  • Base file name will set as json class Name
import 'package:freezed_annotation/freezed_annotation.dart';
part 'api_resp.g.dart';
part 'api_resp.freezed.dart';

@freezed
class ApiResp with _$ApiResp {
	const ApiResp._();
	const factory ApiResp({
		final User? user,
		final Location? location,
		@Default([]) final List<String> devices,
	}) = _ApiResp;
	factory ApiResp.fromJson(Map<String, dynamic> json) => _$ApiRespFromJson(json);
}

@freezed
class Location with _$Location {
	const Location._();
	const factory Location({
		final String? city,
		final String? state,
		final int? zipcode,
	}) = _Location;
	factory Location.fromJson(Map<String, dynamic> json) => _$LocationFromJson(json);
}

@freezed
class User with _$User {
	const User._();
	const factory User({
		final Name? name,
		final int? age,
		final String? email,
	}) = _User;
	factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}

@freezed
class Name with _$Name {
	const Name._();
	const factory Name({
		final String? first,
		final String? last,
	}) = _Name;
	factory Name.fromJson(Map<String, dynamic> json) => _$NameFromJson(json);
}

SideBar GUI

Before

Class to factory

  • Select text

  • Enter name

  • Finish

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft