null-safety #1

Merged
laiiihz merged 2 commits from null-safety into master 4 years ago

@ -0,0 +1,3 @@
{
"flutterSdkVersion": "stable"
}

1
.gitignore vendored

@ -72,3 +72,4 @@ build/
!**/ios/**/default.mode2v3 !**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser !**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3 !**/ios/**/default.perspectivev3
flutter_sdk

@ -0,0 +1,3 @@
{
"dart.flutterSdkPath": "/Users/akufe/fvm/versions/stable"
}

@ -1,3 +1,5 @@
## [0.0.1] - TODO: Add release date. ## [0.1.0-nullsafety.0]
* TODO: Describe initial release. ## [0.0.1]
* first release.

@ -33,7 +33,7 @@ class MyApp extends StatelessWidget {
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key); MyHomePage({Key? key, required this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning // This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect // that it has a State object (defined below) that contains fields that affect
@ -51,20 +51,8 @@ class MyHomePage extends StatefulWidget {
} }
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
String _char = ''; String _char = '';
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done // This method is rerun every time setState is called, for instance as done
@ -101,9 +89,7 @@ class _MyHomePageState extends State<MyHomePage> {
children: <Widget>[ children: <Widget>[
Text( Text(
'$_char', '$_char',
style: TextStyle( style: TextStyle(fontSize: 30),
fontSize: 30
),
), ),
SizedBox( SizedBox(
height: 10, height: 10,
@ -126,7 +112,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Text('易经'), child: Text('易经'),
color: Colors.blue, color: Colors.blue,
), ),
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
_char = RandomCharacter.getEmoji(length: 5); _char = RandomCharacter.getEmoji(length: 5);
@ -138,11 +124,6 @@ class _MyHomePageState extends State<MyHomePage> {
], ],
), ),
), ),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
); );
} }
} }

@ -7,56 +7,56 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.0-nullsafety.1" version: "2.5.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.3" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0-nullsafety.3" version: "1.15.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
name: cupertino_icons name: cupertino_icons
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.0" version: "1.0.2"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -73,28 +73,28 @@ packages:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10-nullsafety.1" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.8.0"
random_character: random_character:
dependency: "direct main" dependency: "direct main"
description: description:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.0.1" version: "0.1.0-nullsafety.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -106,56 +106,56 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.2" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.19-nullsafety.2" version: "0.2.19"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.3" version: "2.1.0"
sdks: sdks:
dart: ">=2.10.0-110 <2.11.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0" flutter: ">=2.0.0"

@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: '>=2.12.0 <3.0.0'
dependencies: dependencies:
flutter: flutter:
@ -27,7 +27,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0 cupertino_icons: ^1.0.2
random_character: random_character:
path: ../ path: ../

@ -1,121 +1,120 @@
import 'dart:math'; import 'dart:math';
class RandomCharacter { class RandomCharacter {
static String getChinese({int length}) { static String getChinese({int length = 2}) {
int max = 0x9FEF - 0x4e00 + 1; int max = 0x9FEF - 0x4e00 + 1;
int base = 0x4e00; int base = 0x4e00;
int r; int r;
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
r = base + Random().nextInt(max); r = base + Random().nextInt(max);
rc = rc + String.fromCharCode(r); rc = rc + String.fromCharCode(r);
} }
return rc; return rc;
} }
static String getYijing({int length}) { static String getYijing({int length = 2}) {
int max = 0x4DE0 - 0x4DC0 + 1; int max = 0x4DE0 - 0x4DC0 + 1;
int base = 0x4DC0; int base = 0x4DC0;
int r; int r;
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
r = base + Random().nextInt(max); r = base + Random().nextInt(max);
rc = rc + String.fromCharCode(r); rc = rc + String.fromCharCode(r);
} }
return rc; return rc;
} }
static String getHiragana({int length}) { static String getHiragana({int length = 2}) {
int max = 0x3080 - 0x3040 + 1; int max = 0x3080 - 0x3040 + 1;
int base = 0x3040; int base = 0x3040;
int r; int r;
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
r = base + Random().nextInt(max); r = base + Random().nextInt(max);
rc = rc + String.fromCharCode(r); rc = rc + String.fromCharCode(r);
} }
return rc; return rc;
} }
static String getkatakana({int length}) { static String getkatakana({int length = 2}) {
int max = 0x30E0 - 0x30A0 + 1; int max = 0x30E0 - 0x30A0 + 1;
int base = 0x30A0; int base = 0x30A0;
int r; int r;
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
r = base + Random().nextInt(max); r = base + Random().nextInt(max);
rc = rc + String.fromCharCode(r); rc = rc + String.fromCharCode(r);
} }
return rc; return rc;
} }
static String getJPCharacter({int length}) { static String getJPCharacter({int length = 2}) {
int max = 0x30E0 - 0x3040 + 1; int max = 0x30E0 - 0x3040 + 1;
int base = 0x3040; int base = 0x3040;
int r; int r;
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
r = base + Random().nextInt(max); r = base + Random().nextInt(max);
rc = rc + String.fromCharCode(r); rc = rc + String.fromCharCode(r);
} }
return rc; return rc;
} }
static String getEmoji({int length}) { static String getEmoji({int length = 2}) {
int max = 0x1F64F - 0x1F601 + 1; int max = 0x1F64F - 0x1F601 + 1;
int base = 0x1F601; int base = 0x1F601;
int r; int r;
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
r = base + Random().nextInt(max); r = base + Random().nextInt(max);
rc = rc + String.fromCharCode(r); rc = rc + String.fromCharCode(r);
} }
return rc; return rc;
} }
static String getNum({int length}) { static String getNum({int length = 2}) {
int max = 0x003A - 0x0030 + 1; int max = 0x003A - 0x0030 + 1;
int base = 0x0030; int base = 0x0030;
int r; int r;
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
r = base + Random().nextInt(max); r = base + Random().nextInt(max);
rc = rc + String.fromCharCode(r); rc = rc + String.fromCharCode(r);
} }
return rc; return rc;
} }
static String getENCharacter({int length}) { static String getENCharacter({int length = 2}) {
String _alphabet = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'; String _alphabet = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
rc = rc + _alphabet[Random().nextInt(_alphabet.length)]; rc = rc + _alphabet[Random().nextInt(_alphabet.length)];
} }
return rc; return rc;
} }
static String getLowerCase({int length}) { static String getLowerCase({int length = 2}) {
String _alphabet = 'qwertyuiopasdfghjklzxcvbnm'; String _alphabet = 'qwertyuiopasdfghjklzxcvbnm';
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
rc = rc + _alphabet[Random().nextInt(_alphabet.length)]; rc = rc + _alphabet[Random().nextInt(_alphabet.length)];
} }
return rc; return rc;
} }
static String getUpperCase({int length}) { static String getUpperCase({int length = 2}) {
String _alphabet = 'QWERTYUIOPASDFGHJKLZXCVBNM'; String _alphabet = 'QWERTYUIOPASDFGHJKLZXCVBNM';
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
rc = rc + _alphabet[Random().nextInt(_alphabet.length)]; rc = rc + _alphabet[Random().nextInt(_alphabet.length)];
} }
return rc; return rc;
} }
static String getCustom(String string, {int length}) { static String getCustom(String string, {int length = 2}) {
assert(string != null);
String rc = ''; String rc = '';
for (var i = 0; i < length ?? 2; i++) { for (var i = 0; i < length; i++) {
rc = rc + string[Random().nextInt(string.length)]; rc = rc + string[Random().nextInt(string.length)];
} }
return rc; return rc;

@ -7,49 +7,49 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.0-nullsafety.1" version: "2.5.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.3" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0-nullsafety.3" version: "1.15.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -66,21 +66,21 @@ packages:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10-nullsafety.1" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.8.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -92,56 +92,56 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.2" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.19-nullsafety.2" version: "0.2.19"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0-nullsafety.3" version: "2.1.0"
sdks: sdks:
dart: ">=2.10.0-110 <2.11.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0" flutter: ">=2.0.0"

@ -1,11 +1,11 @@
name: random_character name: random_character
description: A new Flutter package. description: a random character generator.
version: 0.0.1 version: 0.1.0-nullsafety.0
homepage: https://github.com/meng-fucius/random_character homepage: https://github.com/meng-fucius/random_character
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0" flutter: ">=2.0.0"
dependencies: dependencies:
flutter: flutter:
@ -20,7 +20,6 @@ dev_dependencies:
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter:
# To add assets to your package, add an assets section, like this: # To add assets to your package, add an assets section, like this:
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg
@ -31,7 +30,6 @@ flutter:
# #
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware. # https://flutter.dev/assets-and-images/#resolution-aware.
# To add custom fonts to your package, add a fonts section here, # To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a # in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a # "family" key with the font family name, and a "fonts" key with a

Loading…
Cancel
Save