Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Dec 16, 2022
1 parent 736263f commit 9dff401
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,32 @@ dart pub add webify

```dart
// ignore_for_file: non_constant_identifier_names
import 'package:webify/webify.dart';
void main(List<String> arguments) {
runApp(
port: 8080,
bindIp: "0.0.0.0",
app: MaterialApp(
home: MyApp()
),
app: MaterialApp(home: MyApp()),
);
}
class MyApp extends StatelessWidget {
@override
build() {
return Container(
height: 512,
width: 512,
child: Center(
child: Text("Azka dev Webify framework"),
return Scaffold(
body: Container(
height: 512,
width: 512,
child: Center(
child: Text("Azka dev Webify framework"),
),
),
).build();
);
}
}
```

## FAQS (Pertanyaan)
Expand Down
14 changes: 8 additions & 6 deletions example/bin/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ void main(List<String> arguments) {
class MyApp extends StatelessWidget {
@override
build() {
return Container(
height: 512,
width: 512,
child: Center(
child: Text("Azka dev Webify framework"),
return Scaffold(
body: Container(
height: 512,
width: 512,
child: Center(
child: Text("Azka dev Webify framework"),
),
),
).build();
);
}
}
11 changes: 10 additions & 1 deletion lib/webify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export 'src/webify_base.dart';
part "widget/app.dart";
part "widget/framework.dart";
part "widget/container.dart";
part "widget/scaffold.dart";

void runApp({
int port = 3000,
Expand All @@ -25,10 +26,18 @@ void runApp({
Alfred alfred = Alfred(logLevel: LogType.error);
alfred.all("/", (req, res) {
res.headers.contentType = ContentType.html;
String data = "";
if (app != null) {
if (app.build() is Widget) {
data = (app.build() as Widget).build();
} else if (app.build() is String) {
data = app.build();
}
}
return """
<html>
<body>
${app!.build()}
${data}
</body>
</html>
""";
Expand Down
12 changes: 12 additions & 0 deletions lib/widget/scaffold.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
part of webify;

class Scaffold extends StatefulWidget {
final Widget? body;
Scaffold({
this.body,
});
@override
build() {
return body!.build();
}
}

0 comments on commit 9dff401

Please sign in to comment.