Skip to content

Instantly share code, notes, and snippets.

@li2
Last active March 28, 2024 06:57
Show Gist options
  • Save li2/bed575b06b71360f0ab5dc5639ba95af to your computer and use it in GitHub Desktop.
Save li2/bed575b06b71360f0ab5dc5639ba95af to your computer and use it in GitHub Desktop.
Rfw demo

dart run encode.dart alert.rfwtxt alert.rfw

import core.widgets;
import core.material;
widget Alert = Text(
text: 'Alert: Beware of phishing scams. Do not disclose your login credentials or personal information to anyone!',
textDirection: "ltr",
);
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:rfw/formats.dart';
void main(List<String> arguments) {
if (arguments.length != 2) {
// ignore: avoid_print
print('usage: dart encode.dart source.rfwtxt output.rfw');
exit(1);
}
File(arguments[1]).writeAsBytesSync(
encodeLibraryBlob(
parseLibraryFile(File(arguments[0]).readAsStringSync()),
),
);
}
import 'package:flutter/material.dart';
class EvalDemoWidget extends StatelessWidget {
const EvalDemoWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
textDirection: TextDirection.ltr,
// ignore: always_specify_types
children: [
const Text(
'Eval Dynamic Widget title',
textDirection: TextDirection.ltr,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 24,
),
),
const SizedBox(height: 8),
const Text(
'Eval Dynamic Widget description',
textDirection: TextDirection.ltr,
style: TextStyle(
fontSize: 18,
),
),
const SizedBox(height: 16),
Image.network(
'https://www.gstatic.com/webp/gallery3/2.png',
height: 50,
width: double.infinity,
fit: BoxFit.cover,
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// ignore: prefer_const_literals_to_create_immutables
children: [
const ElevatedButton(
onPressed: null,
child: Text(
'SecondaryButton',
),
),
const ElevatedButton(
onPressed: null,
child: Text(
'PrimaryButton',
),
),
],
),
],
);
}
}
import 'package:flutter/material.dart';
class MyWidget extends StatelessWidget {
const MyWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(5.0),
child: Container(
color: Colors.red,
child: Text(
'Eval Dynamic Widget',
textDirection: TextDirection.ltr,
)));
}
}
import 'package:flutter/material.dart';
class MyWidget extends StatelessWidget {
const MyWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(5.0),
child: Container(
color: Colors.red,
child: Text(
'Eval Dynamic Widget',
textDirection: TextDirection.ltr,
style: TextStyle(
inherit: true,
fontSize: 16,
),
)));
}
}
import core.widgets;
import core.material;
import local;
widget Whatsnew = Column(
crossAxisAlignment: "start",
children: [
Text(
text: "Whatsnew title",
style: TextStyle(
fontWeight: "bold",
fontSize: 24,
),
),
SizedBox(height: 8),
Text(
text: "Whatsnew description",
style: TextStyle(
fontSize: 18,
),
),
SizedBox(height: 16),
image(
url: "https://www.gstatic.com/webp/gallery3/2.png",
),
SizedBox(height: 16),
Row(
mainAxisAlignment: "spaceBetween",
children: [
ElevatedButton(
onPressed: null,
child: Text(text: 'SecondaryButton'),
),
ElevatedButton(
onPressed: null,
child: Text(text: 'PrimaryButton'),
),
],
),
],
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment