Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freecodecamp/phoneide
PhoneIDE freeCodeCamps Mobile Editor Made with Flutter
https://github.com/freecodecamp/phoneide
code-editor-mobile dart flutter hacktoberfest
Last synced: about 20 hours ago
JSON representation
PhoneIDE freeCodeCamps Mobile Editor Made with Flutter
- Host: GitHub
- URL: https://github.com/freecodecamp/phoneide
- Owner: freeCodeCamp
- License: bsd-3-clause
- Created: 2021-11-29T15:10:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-23T16:23:34.000Z (4 months ago)
- Last Synced: 2024-08-22T23:41:10.911Z (3 months ago)
- Topics: code-editor-mobile, dart, flutter, hacktoberfest
- Language: Dart
- Homepage:
- Size: 325 KB
- Stars: 25
- Watchers: 16
- Forks: 9
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Usage
To use PhoneIDE in your Flutter app, simply add the `phone_ide` package to your project dependencies and import the `phone_ide.dart` file. You can then use the `Editor` widget to display the code editor in your app.
```dart
import 'package:flutter/material.dart';
import 'package:flutter_code_editor/phone_ide.dart';void main() {
runApp(const App());
}class App extends StatelessWidget {
const App({Key? key}) : super(key: key);@override
Widget build(BuildContext context) {
return const MaterialApp(
home: EditorView(),
debugShowCheckedModeBanner: false,
);
}
}class EditorView extends StatefulWidget {
const EditorView({
Key? key,
}) : super(key: key);@override
State createState() => EditorViewState();
}class EditorViewState extends State {
Editor editor = Editor(
language: 'html',
options: EditorOptions(
hasRegion: true,
),
);@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
editor.fileTextStream.add(FileIDE(
id: '1',
ext: 'HTML',
name: 'index',
content: """
Hello World!
""",
hasRegion: true,
region: EditorRegionOptions(start: 1, end: 3),
));
});
}@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: editor.fileTextStream.stream,
builder: (context, snapshot) {
return Scaffold(
body: SafeArea(
child: Column(
children: [
Expanded(child: editor),
ElevatedButton(
onPressed: () {
editor.fileTextStream.add(FileIDE(
id: '2',
ext: 'HTML',
name: 'index',
content: """
Hello World from file two!
""",
hasRegion: true,
region: EditorRegionOptions(start: 1, end: 3),
));
},
child: const Text('open another file'),
)
],
),
),
);
},
);
}
}