forked from X-Wei/flutter_catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_highlight/flutter_highlight.dart'; | ||
import 'package:flutter_highlight/themes/github.dart'; | ||
|
||
class CodeHighlightExample extends StatefulWidget { | ||
const CodeHighlightExample({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<CodeHighlightExample> createState() => _CodeHighlightExampleState(); | ||
} | ||
|
||
const kLangToCodeSample = <String, String>{ | ||
'dart': ''' | ||
main() { | ||
print("Hello, World!"); | ||
}''', | ||
'python': 'print("Hello World")', | ||
'cpp': ''' | ||
#include | ||
using namespace std; | ||
int main () { | ||
cout << "Hello World!"; | ||
return 0; | ||
}''', | ||
'java': ''' | ||
class HelloWorldApp { | ||
public static void main(String[] args) { | ||
System.out.println("Hello World!"); | ||
} | ||
}''', | ||
'SQL': "SELECT Country FROM Customers WHERE Country <> 'USA'", | ||
}; | ||
|
||
class _CodeHighlightExampleState extends State<CodeHighlightExample> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return ListView( | ||
padding: const EdgeInsets.all(8), | ||
children: [ | ||
for (final entry in kLangToCodeSample.entries) | ||
Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Text( | ||
'language=${entry.key}', | ||
// strutStyle: Theme.of(context).textTheme.headline2, | ||
), | ||
HighlightView( | ||
entry.value, | ||
language: entry.key, | ||
theme: githubTheme, | ||
), | ||
Divider(), | ||
], | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters