ssr
SSR
- 스타
- 11
- 포크
- 2
- 최근 푸시(UTC)
- 2022. 3. 3.
- 프로젝트 상태
- 활성
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Server Side Rendering
A Backend-Driven UI toolkit, build your dynamic UI with json, and the json format is very similar with flutter widget code.
Install
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
ssr: any
2. Install it
You can install packages from the command line:
with Flutter:
$ flutter pub get
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:ssr/ssr.dart';
Get started
You should use ServerSideRendering.build method to covert a json string into flutter widget. It will be time-consuming. so you'd better using FutureBuilder to build the UI.
import 'package:ssr/ssr.dart';
class PreviewPage extends StatelessWidget {
final Map jsonMap;
PreviewPage(this.jsonMap);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Preview"),
),
body: ServerSideRendering.build(jsonMap, context),
);
}
}
How to implement for custom widgets
This is a RaisedButton widget parser.
import 'package:ssr/ssr.dart';
import 'package:flutter/material.dart';
ServerSideRendering.register('Alignment', {
'bottomCenter': Alignment.bottomCenter,
'bottomLeft': Alignment.bottomLeft,
'bottomRight': Alignment.bottomRight,
'center': Alignment.center,
'centerLeft': Alignment.centerLeft,
'centerRight': Alignment.centerRight,
'topCenter': Alignment.topCenter,
'topLeft': Alignment.topLeft,
'topRight': Alignment.topRight,
});
ServerSideRendering.register('RaisedButton', ({Map args = const {}}) {
return RaisedButton(
color: args['color'],
disabledColor: args['disabledColor'],
disabledElevation: args['disabledElevation'],
disabledTextColor: args['disabledTextColor'],
elevation: args['elevation'],
padding: args['padding'],
splashColor: args['splashColor'],
textColor: args['textColor'],
child: args['child'],
onPressed: () {
},
);
});
How to add a click listener
Add "click_event" property to your widget json definition. for example:
var raisedButton_json = {
'Container': {
'alignment': 'Alignment.center',
'child': {
'RaisedButton' : {
'color': {
'Color': [0xFF00FF],
},
'textColor': {
'Color': [0x00FF00],
},
'splashColor' : {
'Color': [0x00FF00],
},
'click_event' : 'route://productDetail?goods_id=123',
'child' : {
'Text': ['I am a button']
}
}
}
}
};
Widget Documents
Already completed widget/registery:
- Alignment
- AppBar
- Color
- Column
- Container
- Row
- Scaffold
- Text
- TextOverflow
- TextStyle
사용 중인 의존성
의존성 목록 3 개
- flutter
{"sdk":"flutter"} - flutter_test개발 의존성
{"sdk":"flutter"} - flutter_lints개발 의존성
^1.0.0
프로젝트에 맞는 저장소를 선택하려면?
사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
- 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
- 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
- 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.
출처 및 관리
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗