This file contains hidden or 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
| //Based on Flutter 3.7.6 Dart SDK 2.19.3 | |
| import 'package:flutter/material.dart'; | |
| const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
| void main() { | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { |
This file contains hidden or 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
| //https://medium.com/flutter-community/export-your-widget-to-image-with-flutter-dc7ecfa6bafb | |
| ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png); | |
| Uint8List pngBytes = byteData.buffer.asUint8List(); |
This file contains hidden or 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
| Future<ui.Image> load(String asset) async { | |
| ByteData data = await rootBundle.load(asset); | |
| ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); | |
| ui.FrameInfo fi = await codec.getNextFrame(); | |
| return fi.image; | |
| } |
This file contains hidden or 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
| var urlPattern = r"(https?|http)://([-A-Z0-9.]+)(/[-A-Z0-9+&@#/%=~_|!:,.;]*)?(\?[A-Z0-9+&@#/%=~_|!:,.;]*)?"; | |
| RegExp exp = new RegExp(urlPattern, caseSensitive: false); | |
| String str = "Parse https://www.google.com/abc中文 http://www.umc.com/ my string"; | |
| Iterable<Match> matches = exp.allMatches(str); | |
| for (Match m in matches) { | |
| String match = m.group(0); | |
| print(match); | |
| } |
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| import 'dart:math' as math; | |
| import 'package:flutter/rendering.dart'; | |
| //Transform的变换是应用在绘制阶段,而并不是应用在布局(layout)阶段, | |
| // 所以无论对子widget应用何种变化,其占用空间的大小和在屏幕上的位置都是固定不变的, | |
| // 因为这些是在布局阶段就确定的。 | |
| main() { | |
| debugPaintSizeEnabled = true; |
This file contains hidden or 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
| /* | |
| After the 25.1.0 support library was introduced, now is possible to read exif data from URI contents (content:// or file://) through an InputStream. | |
| Example: First add this line to your gradle file: | |
| compile 'com.android.support:exifinterface:25.1.0' | |
| */ | |
| Uri uri; // the URI you've received from the other app | |
| InputStream in; |
This file contains hidden or 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
| import 'dart:io' show Platform; | |
| if (Platform.isAndroid) { | |
| // Android-specific code | |
| } else if (Platform.isIOS) { | |
| // iOS-specific code | |
| } | |
| /* | |
| Other options include: |
This file contains hidden or 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
| Widget frostedEdged(Widget child) { | |
| return ClipRRect( | |
| borderRadius: BorderRadius.circular(15.0), | |
| child: BackdropFilter( | |
| filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), | |
| child: child)); | |
| } |
This file contains hidden or 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
| channel = new IOWebSocketChannel.connect(socketUrl, headers: { | |
| "UID": auth.uid, | |
| "ACCESS_TOKEN": auth.accessToken, | |
| "CLIENT_ID": auth.clientId | |
| }); | |
| channel.sink.add(json.encode({ | |
| "command": "subscribe", | |
| "identifier": "{\"channel\":\"RoomChannel\"}" | |
| })); |
This file contains hidden or 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
| var ws = new WebSocketServer({ | |
| verifyClient: function (info, cb) { | |
| var token = info.req.headers.token | |
| if (!token) | |
| cb(false, 401, 'Unauthorized') | |
| else { | |
| jwt.verify(token, 'secret-key', function (err, decoded) { | |
| if (err) { | |
| cb(false, 401, 'Unauthorized') | |
| } else { |
NewerOlder