feat(deferred): (wip) add annotations package
This commit is contained in:
		
							parent
							
								
									a563bd1fe3
								
							
						
					
					
						commit
						4441ddeb33
					
				
							
								
								
									
										7
									
								
								packages/wyatt_deferred_widget_annotation/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								packages/wyatt_deferred_widget_annotation/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
# https://dart.dev/guides/libraries/private-files
 | 
			
		||||
# Created by `dart pub`
 | 
			
		||||
.dart_tool/
 | 
			
		||||
 | 
			
		||||
# Avoid committing pubspec.lock for library packages; see
 | 
			
		||||
# https://dart.dev/guides/libraries/private-files#pubspeclock.
 | 
			
		||||
pubspec.lock
 | 
			
		||||
							
								
								
									
										24
									
								
								packages/wyatt_deferred_widget_annotation/.vscode/extensions.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								packages/wyatt_deferred_widget_annotation/.vscode/extensions.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2022 WYATT GROUP
 | 
			
		||||
 * Please see the AUTHORS file for details.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    "recommendations": [
 | 
			
		||||
        "psioniq.psi-header",
 | 
			
		||||
        "blaugold.melos-code"
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								packages/wyatt_deferred_widget_annotation/.vscode/launch.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								packages/wyatt_deferred_widget_annotation/.vscode/launch.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
 * Please see the AUTHORS file for details.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    // Use IntelliSense to learn about possible attributes.
 | 
			
		||||
    // Hover to view descriptions of existing attributes.
 | 
			
		||||
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 | 
			
		||||
    "version": "0.2.0",
 | 
			
		||||
    "configurations": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Launch Example",
 | 
			
		||||
            "request": "launch",
 | 
			
		||||
            "type": "dart",
 | 
			
		||||
            "cwd": "example/",
 | 
			
		||||
            "program": "lib/main.dart",
 | 
			
		||||
            "flutterMode": "debug"
 | 
			
		||||
        },
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										72
									
								
								packages/wyatt_deferred_widget_annotation/.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								packages/wyatt_deferred_widget_annotation/.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,72 @@
 | 
			
		||||
{
 | 
			
		||||
  "dart.runPubGetOnPubspecChanges": "never",
 | 
			
		||||
  "bloc.newCubitTemplate.type": "equatable",
 | 
			
		||||
  "psi-header.changes-tracking": {
 | 
			
		||||
    "isActive": true
 | 
			
		||||
  },
 | 
			
		||||
  "psi-header.config": {
 | 
			
		||||
    "blankLinesAfter": 1,
 | 
			
		||||
    "forceToTop": true
 | 
			
		||||
  },
 | 
			
		||||
  "psi-header.lang-config": [
 | 
			
		||||
    {
 | 
			
		||||
      "beforeHeader": [
 | 
			
		||||
        "# -*- coding:utf-8 -*-",
 | 
			
		||||
        "#!/usr/bin/env python3"
 | 
			
		||||
      ],
 | 
			
		||||
      "begin": "###",
 | 
			
		||||
      "end": "###",
 | 
			
		||||
      "language": "python",
 | 
			
		||||
      "prefix": "# "
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "beforeHeader": [
 | 
			
		||||
        "#!/usr/bin/env sh",
 | 
			
		||||
        ""
 | 
			
		||||
      ],
 | 
			
		||||
      "language": "shellscript",
 | 
			
		||||
      "begin": "",
 | 
			
		||||
      "end": "",
 | 
			
		||||
      "prefix": "# "
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "begin": "",
 | 
			
		||||
      "end": "",
 | 
			
		||||
      "language": "dart",
 | 
			
		||||
      "prefix": "// "
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "begin": "",
 | 
			
		||||
      "end": "",
 | 
			
		||||
      "language": "yaml",
 | 
			
		||||
      "prefix": "# "
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "begin": "<!--",
 | 
			
		||||
      "end": "-->",
 | 
			
		||||
      "language": "markdown",
 | 
			
		||||
    },
 | 
			
		||||
  ],
 | 
			
		||||
  "psi-header.templates": [
 | 
			
		||||
    {
 | 
			
		||||
      "language": "*",
 | 
			
		||||
      "template": [
 | 
			
		||||
        "Copyright (C) <<year>> WYATT GROUP",
 | 
			
		||||
        "Please see the AUTHORS file for details.",
 | 
			
		||||
        "",
 | 
			
		||||
        "This program is free software: you can redistribute it and/or modify",
 | 
			
		||||
        "it under the terms of the GNU General Public License as published by",
 | 
			
		||||
        "the Free Software Foundation, either version 3 of the License, or",
 | 
			
		||||
        "any later version.",
 | 
			
		||||
        "",
 | 
			
		||||
        "This program is distributed in the hope that it will be useful,",
 | 
			
		||||
        "but WITHOUT ANY WARRANTY; without even the implied warranty of",
 | 
			
		||||
        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
 | 
			
		||||
        "GNU General Public License for more details.",
 | 
			
		||||
        "",
 | 
			
		||||
        "You should have received a copy of the GNU General Public License",
 | 
			
		||||
        "along with this program. If not, see <https://www.gnu.org/licenses/>."
 | 
			
		||||
      ],
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								packages/wyatt_deferred_widget_annotation/CHANGELOG.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								packages/wyatt_deferred_widget_annotation/CHANGELOG.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
## 1.0.0
 | 
			
		||||
 | 
			
		||||
- Initial version.
 | 
			
		||||
							
								
								
									
										56
									
								
								packages/wyatt_deferred_widget_annotation/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								packages/wyatt_deferred_widget_annotation/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,56 @@
 | 
			
		||||
<!--
 | 
			
		||||
 * Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
 * Please see the AUTHORS file for details.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful, 
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Flutter - Wyatt Deferred Widget Annotation
 | 
			
		||||
 | 
			
		||||
<p align="left">
 | 
			
		||||
  <a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
 | 
			
		||||
  <img src="https://img.shields.io/badge/SDK-Flutter-blue?style=flat-square" alt="SDK: Flutter" />
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
A package by wyatt studio
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
 | 
			
		||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
 | 
			
		||||
 | 
			
		||||
## Getting started
 | 
			
		||||
 | 
			
		||||
TODO: List prerequisites and provide or point to information on how to
 | 
			
		||||
start using the package.
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
TODO: Include short and useful examples for package users. Add longer examples
 | 
			
		||||
to `/example` folder. 
 | 
			
		||||
 | 
			
		||||
```dart
 | 
			
		||||
const like = 'sample';
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Additional information
 | 
			
		||||
 | 
			
		||||
TODO: Tell users more about the package: where to find more information, how to 
 | 
			
		||||
contribute to the package, how to file issues, what response they can expect 
 | 
			
		||||
from the package authors, and more.
 | 
			
		||||
@ -0,0 +1,7 @@
 | 
			
		||||
 | 
			
		||||
include: package:wyatt_analysis/analysis_options.flutter.yaml
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										44
									
								
								packages/wyatt_deferred_widget_annotation/example/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								packages/wyatt_deferred_widget_annotation/example/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
# Miscellaneous
 | 
			
		||||
*.class
 | 
			
		||||
*.log
 | 
			
		||||
*.pyc
 | 
			
		||||
*.swp
 | 
			
		||||
.DS_Store
 | 
			
		||||
.atom/
 | 
			
		||||
.buildlog/
 | 
			
		||||
.history
 | 
			
		||||
.svn/
 | 
			
		||||
migrate_working_dir/
 | 
			
		||||
 | 
			
		||||
# IntelliJ related
 | 
			
		||||
*.iml
 | 
			
		||||
*.ipr
 | 
			
		||||
*.iws
 | 
			
		||||
.idea/
 | 
			
		||||
 | 
			
		||||
# The .vscode folder contains launch configuration and tasks you configure in
 | 
			
		||||
# VS Code which you may wish to be included in version control, so this line
 | 
			
		||||
# is commented out by default.
 | 
			
		||||
#.vscode/
 | 
			
		||||
 | 
			
		||||
# Flutter/Dart/Pub related
 | 
			
		||||
**/doc/api/
 | 
			
		||||
**/ios/Flutter/.last_build_id
 | 
			
		||||
.dart_tool/
 | 
			
		||||
.flutter-plugins
 | 
			
		||||
.flutter-plugins-dependencies
 | 
			
		||||
.packages
 | 
			
		||||
.pub-cache/
 | 
			
		||||
.pub/
 | 
			
		||||
/build/
 | 
			
		||||
 | 
			
		||||
# Symbolication related
 | 
			
		||||
app.*.symbols
 | 
			
		||||
 | 
			
		||||
# Obfuscation related
 | 
			
		||||
app.*.map.json
 | 
			
		||||
 | 
			
		||||
# Android Studio will place build artifacts here
 | 
			
		||||
/android/app/debug
 | 
			
		||||
/android/app/profile
 | 
			
		||||
/android/app/release
 | 
			
		||||
							
								
								
									
										30
									
								
								packages/wyatt_deferred_widget_annotation/example/.metadata
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								packages/wyatt_deferred_widget_annotation/example/.metadata
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
# This file tracks properties of this Flutter project.
 | 
			
		||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
 | 
			
		||||
#
 | 
			
		||||
# This file should be version controlled.
 | 
			
		||||
 | 
			
		||||
version:
 | 
			
		||||
  revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
 | 
			
		||||
  channel: stable
 | 
			
		||||
 | 
			
		||||
project_type: app
 | 
			
		||||
 | 
			
		||||
# Tracks metadata for the flutter migrate command
 | 
			
		||||
migration:
 | 
			
		||||
  platforms:
 | 
			
		||||
    - platform: root
 | 
			
		||||
      create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
 | 
			
		||||
      base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
 | 
			
		||||
    - platform: web
 | 
			
		||||
      create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
 | 
			
		||||
      base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
 | 
			
		||||
 | 
			
		||||
  # User provided section
 | 
			
		||||
 | 
			
		||||
  # List of Local paths (relative to this file) that should be
 | 
			
		||||
  # ignored by the migrate tool.
 | 
			
		||||
  #
 | 
			
		||||
  # Files that are not part of the templates will be ignored by default.
 | 
			
		||||
  unmanaged_files:
 | 
			
		||||
    - 'lib/main.dart'
 | 
			
		||||
    - 'ios/Runner.xcodeproj/project.pbxproj'
 | 
			
		||||
							
								
								
									
										16
									
								
								packages/wyatt_deferred_widget_annotation/example/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								packages/wyatt_deferred_widget_annotation/example/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
# example
 | 
			
		||||
 | 
			
		||||
A new Flutter project.
 | 
			
		||||
 | 
			
		||||
## Getting Started
 | 
			
		||||
 | 
			
		||||
This project is a starting point for a Flutter application.
 | 
			
		||||
 | 
			
		||||
A few resources to get you started if this is your first Flutter project:
 | 
			
		||||
 | 
			
		||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
 | 
			
		||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
 | 
			
		||||
 | 
			
		||||
For help getting started with Flutter development, view the
 | 
			
		||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
 | 
			
		||||
samples, guidance on mobile development, and a full API reference.
 | 
			
		||||
@ -0,0 +1,7 @@
 | 
			
		||||
 | 
			
		||||
include: package:wyatt_analysis/analysis_options.flutter.yaml
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,60 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation/wyatt_deferred_widget_annotation.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation_example/widgets/my_awesome_widget1_deferred.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation_example/widgets/my_awesome_widget2_deferred.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation_example/widgets/my_awesome_widget3.dart';
 | 
			
		||||
 | 
			
		||||
void main(List<String> args) {
 | 
			
		||||
  Deferred.placeholderBuilder = (context) => const CircularProgressIndicator();
 | 
			
		||||
  runApp(const App());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class App extends StatelessWidget {
 | 
			
		||||
  const App({super.key});
 | 
			
		||||
 | 
			
		||||
  static const String title = 'Wyatt Deferred Widget Annotation Example';
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) => MaterialApp(
 | 
			
		||||
        title: title,
 | 
			
		||||
        theme: ThemeData(
 | 
			
		||||
          primarySwatch: Colors.blue,
 | 
			
		||||
        ),
 | 
			
		||||
        home: Scaffold(
 | 
			
		||||
          appBar: AppBar(
 | 
			
		||||
            title: const Text(title),
 | 
			
		||||
          ),
 | 
			
		||||
          body: Builder(
 | 
			
		||||
            builder: (context) => ListView(
 | 
			
		||||
              children: [
 | 
			
		||||
                const MyAwesomeWidget3(),
 | 
			
		||||
                MyAwesomeWidget2Deferred(
 | 
			
		||||
                  placeholderSize: MediaQuery.of(context).size,
 | 
			
		||||
                ),
 | 
			
		||||
                MyAwesomeWidget1Deferred(
 | 
			
		||||
                  color: Colors.yellow,
 | 
			
		||||
                  placeholderBuilder: (context) =>
 | 
			
		||||
                      const LinearProgressIndicator(),
 | 
			
		||||
                ),
 | 
			
		||||
              ],
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
        ),
 | 
			
		||||
      );
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,35 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation/wyatt_deferred_widget_annotation.dart';
 | 
			
		||||
 | 
			
		||||
@Deferred()
 | 
			
		||||
class MyAwesomeWidget1 extends StatelessWidget {
 | 
			
		||||
  const MyAwesomeWidget1({required this.color, super.key});
 | 
			
		||||
 | 
			
		||||
  final Color color;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) => Container(
 | 
			
		||||
        height: MediaQuery.of(context).size.height,
 | 
			
		||||
        width: MediaQuery.of(context).size.width,
 | 
			
		||||
        color: color,
 | 
			
		||||
        child: const Center(
 | 
			
		||||
          child: Text('MyAwesomeWidget1'),
 | 
			
		||||
        ),
 | 
			
		||||
      );
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,72 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation/wyatt_deferred_widget_annotation.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation_example/widgets/my_awesome_widget1.dart'
 | 
			
		||||
    deferred as my_awesome_widget1;
 | 
			
		||||
 | 
			
		||||
class MyAwesomeWidget1Deferred extends StatefulWidget {
 | 
			
		||||
  const MyAwesomeWidget1Deferred({
 | 
			
		||||
    required this.color,
 | 
			
		||||
    this.placeholderBuilder,
 | 
			
		||||
    super.key,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  final Color color;
 | 
			
		||||
 | 
			
		||||
  final Widget Function(BuildContext context)? placeholderBuilder;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  State<MyAwesomeWidget1Deferred> createState() =>
 | 
			
		||||
      MyAwesomeWidget1DeferredState();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class MyAwesomeWidget1DeferredState extends State<MyAwesomeWidget1Deferred> {
 | 
			
		||||
  static bool loaded = false;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void initState() {
 | 
			
		||||
    load();
 | 
			
		||||
    super.initState();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<void> load() async {
 | 
			
		||||
    await my_awesome_widget1.loadLibrary();
 | 
			
		||||
    await Future.delayed(const Duration(seconds: 1));
 | 
			
		||||
    if (mounted) {
 | 
			
		||||
      setState(() {
 | 
			
		||||
        loaded = true;
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    if (!loaded) {
 | 
			
		||||
      if (widget.placeholderBuilder != null) {
 | 
			
		||||
        return widget.placeholderBuilder!.call(context);
 | 
			
		||||
      }
 | 
			
		||||
      if (Deferred.placeholderBuilder != null) {
 | 
			
		||||
        return Deferred.placeholderBuilder!.call(context);
 | 
			
		||||
      }
 | 
			
		||||
      return const SizedBox.shrink();
 | 
			
		||||
    }
 | 
			
		||||
    return my_awesome_widget1.MyAwesomeWidget1(
 | 
			
		||||
      color: widget.color,
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,31 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
class MyAwesomeWidget2 extends StatelessWidget {
 | 
			
		||||
  const MyAwesomeWidget2({super.key});
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) => Container(
 | 
			
		||||
        height: MediaQuery.of(context).size.height,
 | 
			
		||||
        width: MediaQuery.of(context).size.width,
 | 
			
		||||
        color: Colors.green,
 | 
			
		||||
        child: const Center(
 | 
			
		||||
          child: Text('MyAwesomeWidget2'),
 | 
			
		||||
        ),
 | 
			
		||||
      );
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,83 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation/wyatt_deferred_widget_annotation.dart';
 | 
			
		||||
import 'package:wyatt_deferred_widget_annotation_example/widgets/my_awesome_widget2.dart'
 | 
			
		||||
    deferred as my_awesome_widget2;
 | 
			
		||||
 | 
			
		||||
class MyAwesomeWidget2Deferred extends StatefulWidget {
 | 
			
		||||
  const MyAwesomeWidget2Deferred({
 | 
			
		||||
    this.placeholderBuilder,
 | 
			
		||||
    this.placeholderSize,
 | 
			
		||||
    super.key,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  /// Widget builder for the placeholder.
 | 
			
		||||
  /// 
 | 
			
		||||
  /// Prior over the global placeholder defined in [Deferred].
 | 
			
		||||
  final Widget Function(BuildContext context)? placeholderBuilder;
 | 
			
		||||
 | 
			
		||||
  /// Size for the placeholder builder.
 | 
			
		||||
  /// 
 | 
			
		||||
  /// Useful to build a global placeholder defined in [Deferred] with
 | 
			
		||||
  /// different size depending of the widget.
 | 
			
		||||
  final Size? placeholderSize;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  State<MyAwesomeWidget2Deferred> createState() =>
 | 
			
		||||
      MyAwesomeWidget2DeferredState();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class MyAwesomeWidget2DeferredState extends State<MyAwesomeWidget2Deferred> {
 | 
			
		||||
  static bool loaded = false;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void initState() {
 | 
			
		||||
    load();
 | 
			
		||||
    super.initState();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<void> load() async {
 | 
			
		||||
    await my_awesome_widget2.loadLibrary();
 | 
			
		||||
    await Future.delayed(const Duration(seconds: 1));
 | 
			
		||||
    if (mounted) {
 | 
			
		||||
      setState(() {
 | 
			
		||||
        loaded = true;
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    if (!loaded) {
 | 
			
		||||
      if (widget.placeholderBuilder != null) {
 | 
			
		||||
        return SizedBox.fromSize(
 | 
			
		||||
          size: widget.placeholderSize,
 | 
			
		||||
          child: widget.placeholderBuilder!.call(context),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
      if (Deferred.placeholderBuilder != null) {
 | 
			
		||||
        return SizedBox.fromSize(
 | 
			
		||||
          size: widget.placeholderSize,
 | 
			
		||||
          child: Deferred.placeholderBuilder!.call(context),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
      return const SizedBox.shrink();
 | 
			
		||||
    }
 | 
			
		||||
    return my_awesome_widget2.MyAwesomeWidget2();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,36 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
class MyAwesomeWidget3 extends StatefulWidget {
 | 
			
		||||
  const MyAwesomeWidget3({super.key});
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  State<MyAwesomeWidget3> createState() => _MyAwesomeWidget3State();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _MyAwesomeWidget3State extends State<MyAwesomeWidget3> {
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) => Container(
 | 
			
		||||
        height: MediaQuery.of(context).size.height,
 | 
			
		||||
        width: MediaQuery.of(context).size.width,
 | 
			
		||||
        color: Colors.blue,
 | 
			
		||||
        child: const Center(
 | 
			
		||||
          child: Text('MyAwesomeWidget3'),
 | 
			
		||||
        ),
 | 
			
		||||
      );
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,25 @@
 | 
			
		||||
name: wyatt_deferred_widget_annotation_example
 | 
			
		||||
description: A new Flutter project.
 | 
			
		||||
version: 1.0.0
 | 
			
		||||
 | 
			
		||||
publish_to: "none"
 | 
			
		||||
 | 
			
		||||
environment:
 | 
			
		||||
  sdk: ">=2.19.0 <3.0.0"
 | 
			
		||||
 | 
			
		||||
dependencies:
 | 
			
		||||
  flutter: { sdk: flutter }
 | 
			
		||||
 | 
			
		||||
  wyatt_deferred_widget_annotation:
 | 
			
		||||
    path: "../"
 | 
			
		||||
 | 
			
		||||
dev_dependencies:
 | 
			
		||||
  flutter_test: { sdk: flutter }
 | 
			
		||||
 | 
			
		||||
  wyatt_analysis:
 | 
			
		||||
    hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
 | 
			
		||||
    version: ^2.3.0
 | 
			
		||||
 | 
			
		||||
# The following section is specific to Flutter.
 | 
			
		||||
flutter:
 | 
			
		||||
  uses-material-design: true
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 917 B  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 5.2 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 8.1 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 5.5 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 20 KiB  | 
@ -0,0 +1,59 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
  <!--
 | 
			
		||||
    If you are serving your web app in a path other than the root, change the
 | 
			
		||||
    href value below to reflect the base path you are serving from.
 | 
			
		||||
 | 
			
		||||
    The path provided below has to start and end with a slash "/" in order for
 | 
			
		||||
    it to work correctly.
 | 
			
		||||
 | 
			
		||||
    For more details:
 | 
			
		||||
    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
 | 
			
		||||
 | 
			
		||||
    This is a placeholder for base href that will be replaced by the value of
 | 
			
		||||
    the `--base-href` argument provided to `flutter build`.
 | 
			
		||||
  -->
 | 
			
		||||
  <base href="$FLUTTER_BASE_HREF">
 | 
			
		||||
 | 
			
		||||
  <meta charset="UTF-8">
 | 
			
		||||
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
 | 
			
		||||
  <meta name="description" content="A new Flutter project.">
 | 
			
		||||
 | 
			
		||||
  <!-- iOS meta tags & icons -->
 | 
			
		||||
  <meta name="apple-mobile-web-app-capable" content="yes">
 | 
			
		||||
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
 | 
			
		||||
  <meta name="apple-mobile-web-app-title" content="example">
 | 
			
		||||
  <link rel="apple-touch-icon" href="icons/Icon-192.png">
 | 
			
		||||
 | 
			
		||||
  <!-- Favicon -->
 | 
			
		||||
  <link rel="icon" type="image/png" href="favicon.png"/>
 | 
			
		||||
 | 
			
		||||
  <title>example</title>
 | 
			
		||||
  <link rel="manifest" href="manifest.json">
 | 
			
		||||
 | 
			
		||||
  <script>
 | 
			
		||||
    // The value below is injected by flutter build, do not touch.
 | 
			
		||||
    var serviceWorkerVersion = null;
 | 
			
		||||
  </script>
 | 
			
		||||
  <!-- This script adds the flutter initialization JS code -->
 | 
			
		||||
  <script src="flutter.js" defer></script>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <script>
 | 
			
		||||
    window.addEventListener('load', function(ev) {
 | 
			
		||||
      // Download main.dart.js
 | 
			
		||||
      _flutter.loader.loadEntrypoint({
 | 
			
		||||
        serviceWorker: {
 | 
			
		||||
          serviceWorkerVersion: serviceWorkerVersion,
 | 
			
		||||
        },
 | 
			
		||||
        onEntrypointLoaded: function(engineInitializer) {
 | 
			
		||||
          engineInitializer.initializeEngine().then(function(appRunner) {
 | 
			
		||||
            appRunner.runApp();
 | 
			
		||||
          });
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
  </script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
@ -0,0 +1,35 @@
 | 
			
		||||
{
 | 
			
		||||
    "name": "example",
 | 
			
		||||
    "short_name": "example",
 | 
			
		||||
    "start_url": ".",
 | 
			
		||||
    "display": "standalone",
 | 
			
		||||
    "background_color": "#0175C2",
 | 
			
		||||
    "theme_color": "#0175C2",
 | 
			
		||||
    "description": "A new Flutter project.",
 | 
			
		||||
    "orientation": "portrait-primary",
 | 
			
		||||
    "prefer_related_applications": false,
 | 
			
		||||
    "icons": [
 | 
			
		||||
        {
 | 
			
		||||
            "src": "icons/Icon-192.png",
 | 
			
		||||
            "sizes": "192x192",
 | 
			
		||||
            "type": "image/png"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "src": "icons/Icon-512.png",
 | 
			
		||||
            "sizes": "512x512",
 | 
			
		||||
            "type": "image/png"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "src": "icons/Icon-maskable-192.png",
 | 
			
		||||
            "sizes": "192x192",
 | 
			
		||||
            "type": "image/png",
 | 
			
		||||
            "purpose": "maskable"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "src": "icons/Icon-maskable-512.png",
 | 
			
		||||
            "sizes": "512x512",
 | 
			
		||||
            "type": "image/png",
 | 
			
		||||
            "purpose": "maskable"
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,26 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/widgets.dart';
 | 
			
		||||
 | 
			
		||||
class Deferred {
 | 
			
		||||
  const Deferred();
 | 
			
		||||
 | 
			
		||||
  /// Global widget builder used in deferred widget by default.
 | 
			
		||||
  static Widget Function(BuildContext context)? placeholderBuilder;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const Deferred deferred = Deferred();
 | 
			
		||||
@ -0,0 +1,20 @@
 | 
			
		||||
// Copyright (C) 2023 WYATT GROUP
 | 
			
		||||
// Please see the AUTHORS file for details.
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
// GNU General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU General Public License
 | 
			
		||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
/// A package by wyatt studio
 | 
			
		||||
library wyatt_deferred_widget_annotation;
 | 
			
		||||
 | 
			
		||||
export './src/deferred.dart';
 | 
			
		||||
							
								
								
									
										22
									
								
								packages/wyatt_deferred_widget_annotation/pubspec.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								packages/wyatt_deferred_widget_annotation/pubspec.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
name: wyatt_deferred_widget_annotation
 | 
			
		||||
description: A package by wyatt studio.
 | 
			
		||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_deferred_widget_annotation
 | 
			
		||||
version: 1.0.0
 | 
			
		||||
 | 
			
		||||
environment:
 | 
			
		||||
  sdk: ">=2.19.0 <3.0.0"
 | 
			
		||||
 | 
			
		||||
dependencies:
 | 
			
		||||
  flutter: { sdk: flutter }
 | 
			
		||||
  meta: ^1.8.0
 | 
			
		||||
 | 
			
		||||
dev_dependencies:
 | 
			
		||||
  flutter_test: { sdk: flutter }
 | 
			
		||||
 | 
			
		||||
  wyatt_analysis:
 | 
			
		||||
    hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
 | 
			
		||||
    version: ^2.4.0
 | 
			
		||||
 | 
			
		||||
# The following section is specific to Flutter.
 | 
			
		||||
flutter:
 | 
			
		||||
  uses-material-design: true
 | 
			
		||||
@ -0,0 +1 @@
 | 
			
		||||
// TODO(wyatt): add some tests
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user