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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ mason-lock.json

# Cursor Files
.cursor/

# FVM Version Cache
.fvm/
8 changes: 0 additions & 8 deletions examples/movie_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
freezed_annotation:
dependency: transitive
description:
name: freezed_annotation
sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
http:
dependency: transitive
description:
Expand Down
28 changes: 7 additions & 21 deletions packages/stac/lib/src/framework/stac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import 'package:stac_core/actions/network_request/stac_network_request.dart';
import 'package:stac_core/core/stac_options.dart';
import 'package:stac_framework/stac_framework.dart';

typedef ErrorWidgetBuilder = Widget Function(
BuildContext context,
dynamic error,
);
typedef ErrorWidgetBuilder =
Widget Function(BuildContext context, dynamic error);

typedef LoadingWidgetBuilder = Widget Function(BuildContext context);

Expand All @@ -31,10 +29,8 @@ typedef LoadingWidgetBuilder = Widget Function(BuildContext context);
/// },
/// );
/// ```
typedef StacErrorWidgetBuilder = Widget Function(
BuildContext context,
StacError errorDetails,
);
typedef StacErrorWidgetBuilder =
Widget Function(BuildContext context, StacError errorDetails);

class Stac extends StatelessWidget {
const Stac({
Expand Down Expand Up @@ -79,10 +75,7 @@ class Stac extends StatelessWidget {
);
}

static Widget? fromJson(
Map<String, dynamic>? json,
BuildContext context,
) {
static Widget? fromJson(Map<String, dynamic>? json, BuildContext context) {
return StacService.fromJson(json, context);
}

Expand Down Expand Up @@ -139,10 +132,7 @@ class _StacView extends StatelessWidget {
}

return FutureBuilder<Response?>(
future: StacCloud.fetchScreen(
context: context,
routeName: routeName,
),
future: StacCloud.fetchScreen(context: context, routeName: routeName),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return loadingWidget ?? const _LoadingWidget();
Expand All @@ -166,10 +156,6 @@ class _LoadingWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Scaffold(
body: const Center(
child: CircularProgressIndicator(),
),
);
return Scaffold(body: const Center(child: CircularProgressIndicator()));
}
}
28 changes: 14 additions & 14 deletions packages/stac/lib/src/framework/stac_app.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:stac/src/parsers/theme/stac_theme/stac_theme.dart';
import 'package:stac/src/parsers/theme/themes.dart';

class StacApp extends StatelessWidget {
const StacApp({
Expand Down Expand Up @@ -41,11 +41,11 @@ class StacApp extends StatelessWidget {
this.restorationScopeId,
this.scrollBehavior,
this.useInheritedMediaQuery = false,
}) : routeInformationProvider = null,
routeInformationParser = null,
routerDelegate = null,
backButtonDispatcher = null,
routerConfig = null;
}) : routeInformationProvider = null,
routeInformationParser = null,
routerDelegate = null,
backButtonDispatcher = null,
routerConfig = null;

const StacApp.router({
super.key,
Expand Down Expand Up @@ -82,14 +82,14 @@ class StacApp extends StatelessWidget {
this.restorationScopeId,
this.scrollBehavior,
this.useInheritedMediaQuery = false,
}) : navigatorObservers = null,
navigatorKey = null,
onGenerateRoute = null,
homeBuilder = null,
onGenerateInitialRoutes = null,
onUnknownRoute = null,
routes = null,
initialRoute = null;
}) : navigatorObservers = null,
navigatorKey = null,
onGenerateRoute = null,
homeBuilder = null,
onGenerateInitialRoutes = null,
onUnknownRoute = null,
routes = null,
initialRoute = null;

final GlobalKey<NavigatorState>? navigatorKey;
final GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey;
Expand Down
38 changes: 13 additions & 25 deletions packages/stac/lib/src/framework/stac_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ class StacError {
/// The [error] parameter is required and should contain the actual
/// error or exception that was thrown. All other parameters are optional
/// but recommended for better error diagnostics.
const StacError({
this.type,
required this.error,
this.json,
this.stackTrace,
});
const StacError({this.type, required this.error, this.json, this.stackTrace});

/// The type identifier of the failing Stac entity.
///
Expand Down Expand Up @@ -117,10 +112,7 @@ class StacError {
/// )
/// ```
class StacErrorWidget extends StatefulWidget {
const StacErrorWidget({
super.key,
required this.errorDetails,
});
const StacErrorWidget({super.key, required this.errorDetails});

final StacError errorDetails;

Expand Down Expand Up @@ -212,16 +204,16 @@ class _StacErrorWidgetState extends State<StacErrorWidget> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Icon(Icons.warning_amber,
color: _warningOrange, size: 16),
const Icon(
Icons.warning_amber,
color: _warningOrange,
size: 16,
),
const SizedBox(width: 8),
Expanded(
child: Text(
widget.errorDetails.error.toString(),
style: const TextStyle(
color: _errorRed,
fontSize: 13,
),
style: const TextStyle(color: _errorRed, fontSize: 13),
),
),
],
Expand All @@ -239,9 +231,7 @@ class _StacErrorWidgetState extends State<StacErrorWidget> {
_buildExpandableSection(
title: 'JSON Data',
section: _ExpandableSection.json,
child: _buildCodeBlock(
_formatJson(widget.errorDetails.json!),
),
child: _buildCodeBlock(_formatJson(widget.errorDetails.json!)),
),
const SizedBox(height: 8),
],
Expand Down Expand Up @@ -391,18 +381,16 @@ class _StacErrorWidgetState extends State<StacErrorWidget> {
),
),
),
if (isExpanded) ...[
const SizedBox(height: 4),
child,
],
if (isExpanded) ...[const SizedBox(height: 4), child],
],
);
}

String _getTroubleshootingTips() {
final errorStr = widget.errorDetails.error.toString().toLowerCase();
final errorType =
widget.errorDetails.error.runtimeType.toString().toLowerCase();
final errorType = widget.errorDetails.error.runtimeType
.toString()
.toLowerCase();

// Check for unregistered widget/action types
if (errorStr.contains('type') && errorStr.contains('not found')) {
Expand Down
30 changes: 14 additions & 16 deletions packages/stac/lib/src/framework/stac_registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,22 @@ class StacRegistry {
}
}

Future<dynamic> registerAll(List<StacParser> parsers,
[bool override = false]) {
return Future.forEach(
parsers,
(StacParser parser) {
return register(parser, override);
},
);
Future<dynamic> registerAll(
List<StacParser> parsers, [
bool override = false,
]) {
return Future.forEach(parsers, (StacParser parser) {
return register(parser, override);
});
}

Future<dynamic> registerAllActions(List<StacActionParser> parsers,
[bool override = false]) {
return Future.forEach(
parsers,
(StacActionParser parser) {
return registerAction(parser, override);
},
);
Future<dynamic> registerAllActions(
List<StacActionParser> parsers, [
bool override = false,
]) {
return Future.forEach(parsers, (StacActionParser parser) {
return registerAction(parser, override);
});
}

StacParser<dynamic>? getParser(String type) {
Expand Down
10 changes: 4 additions & 6 deletions packages/stac/lib/src/framework/stac_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ class StacService {
_errorWidgetBuilder = errorWidgetBuilder;
}

static Widget? fromJson(
Map<String, dynamic>? json,
BuildContext context,
) {
static Widget? fromJson(Map<String, dynamic>? json, BuildContext context) {
try {
if (json == null) {
return null;
Expand Down Expand Up @@ -318,8 +315,9 @@ class StacService {
throw TypeError();
}

final stacActionParser =
StacRegistry.instance.getActionParser(actionType);
final stacActionParser = StacRegistry.instance.getActionParser(
actionType,
);

if (stacActionParser == null) {
Log.w('Action type [$actionType] not supported');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ class StacDialogActionParser extends StacActionParser<StacDialogAction> {
Stac.fromJson(model.widget, context) ?? const SizedBox(),
);
} else if (model.assetPath?.isNotEmpty ?? false) {
return _showDialog(
context,
model,
Stac.fromAssets(model.assetPath!),
);
return _showDialog(context, model, Stac.fromAssets(model.assetPath!));
} else if (model.request != null) {
return _showDialog(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ class StacNavigateActionParser extends StacActionParser<StacNavigateAction> {
break;

case NavigationStyle.pushNamed:
return Navigator.pushNamed(
context,
routeName!,
arguments: arguments,
);
return Navigator.pushNamed(context, routeName!, arguments: arguments);

case NavigationStyle.pushNamedAndRemoveAll:
return Navigator.pushNamedAndRemoveUntil(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class StacSnackBarParser extends StacActionParser<StacSnackBar> {
}

SnackBarAction? _parseAction(
BuildContext context, StacSnackBarAction? action) {
BuildContext context,
StacSnackBarAction? action,
) {
if (action == null) return null;
return SnackBarAction(
textColor: action.textColor?.toColor(context),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ import 'stac_tile_mode_parser.dart';
extension StacGradientParser on StacGradient {
Gradient? parse(BuildContext context) {
Gradient linearGradient() => LinearGradient(
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
begin: begin?.parse ?? Alignment.centerLeft,
end: end?.parse ?? Alignment.centerRight,
stops: stops,
tileMode: tileMode?.parse ?? TileMode.clamp,
);
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
begin: begin?.parse ?? Alignment.centerLeft,
end: end?.parse ?? Alignment.centerRight,
stops: stops,
tileMode: tileMode?.parse ?? TileMode.clamp,
);

Gradient radialGradient() => RadialGradient(
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
stops: stops,
tileMode: tileMode?.parse ?? TileMode.clamp,
focal: focal?.parse,
focalRadius: focalRadius ?? 0.0,
radius: radius ?? 0.5,
center: center?.parse ?? Alignment.center,
);
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
stops: stops,
tileMode: tileMode?.parse ?? TileMode.clamp,
focal: focal?.parse,
focalRadius: focalRadius ?? 0.0,
radius: radius ?? 0.5,
center: center?.parse ?? Alignment.center,
);

Gradient sweepGradient() => SweepGradient(
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
stops: stops,
center: center?.parse ?? Alignment.center,
startAngle: startAngle ?? 0.0,
endAngle: endAngle ?? math.pi * 2,
tileMode: tileMode?.parse ?? TileMode.clamp,
);
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
stops: stops,
center: center?.parse ?? Alignment.center,
startAngle: startAngle ?? 0.0,
endAngle: endAngle ?? math.pi * 2,
tileMode: tileMode?.parse ?? TileMode.clamp,
);

switch (gradientType) {
case StacGradientType.linear:
Expand Down
3 changes: 3 additions & 0 deletions packages/stac/lib/src/parsers/foundation/foundation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export 'layout/stac_wrap_cross_alignment_parser.dart';
export 'navigation/stac_bottom_navigation_bar_landscape_layout_parser.dart';
export 'navigation/stac_bottom_navigation_bar_type_parser.dart';
export 'navigation/stac_floating_action_button_location_parser.dart';
export 'navigation/stac_navigation_destination_label_behavior_parser.dart';
export 'navigation/stac_tab_alignment_parser.dart';
export 'navigation/stac_tab_bar_indicator_size_parser.dart';
// Text parsers
Expand All @@ -91,6 +92,8 @@ export 'text/stac_text_overflow_parser.dart';
export 'text/stac_text_style_parser.dart';
export 'text/stac_text_width_basis_parser.dart';
// Theme parsers
export 'theme/stac_button_bar_layout_behavior_parser.dart';
export 'theme/stac_button_text_theme_parser.dart';
export 'theme/stac_input_decoration_theme_parser.dart';
// UI component parsers
export 'ui_components/stac_dismiss_direction_parser.dart';
Expand Down
Loading