diff --git a/deprecated/cupertino_controllers/example/lib/main.dart b/deprecated/cupertino_controllers/example/lib/main.dart index e495a08..3c25d45 100644 --- a/deprecated/cupertino_controllers/example/lib/main.dart +++ b/deprecated/cupertino_controllers/example/lib/main.dart @@ -4,7 +4,6 @@ import 'tabs/master_detail_controller.dart'; import 'tabs/table_view_controller.dart'; -import 'package:flutter/foundation.dart'; void main() => runApp(MyApp()); @@ -26,11 +25,11 @@ class CupertinoControllersApp extends StatelessWidget { items: [ BottomNavigationBarItem( icon: Icon(Icons.list), - title: Text("Table"), + label: Text("Table"), ), BottomNavigationBarItem( icon: Icon(Icons.layers), - title: Text("Mater Detail"), + label: Text("Mater Detail"), ), ], ), @@ -41,9 +40,9 @@ class CupertinoControllersApp extends StatelessWidget { ]; return CupertinoTabView( builder: (BuildContext context) { - return pages[index]?.child; + return pages[index].child; }, - defaultTitle: pages[index]?.title, + defaultTitle: pages[index].title, ); ; }, diff --git a/deprecated/cupertino_controllers/example/lib/tabs/table_view_controller.dart b/deprecated/cupertino_controllers/example/lib/tabs/table_view_controller.dart index 7f8f8c5..042ff2e 100644 --- a/deprecated/cupertino_controllers/example/lib/tabs/table_view_controller.dart +++ b/deprecated/cupertino_controllers/example/lib/tabs/table_view_controller.dart @@ -80,7 +80,7 @@ class TableViewScreenState extends State var _sections = []; _sections = _buildSections(context, - data: _search != null && _search.isNotEmpty + data: _search.isNotEmpty ? _searchItems(context, search: _search) : contacts); @@ -117,10 +117,9 @@ class TableViewScreenState extends State }); }, onChanged: (String value) { - if (value != null) - setState(() { - _search = value; - }); + setState(() { + _search = value; + }); }, ), ), @@ -144,17 +143,15 @@ class TableViewScreenState extends State }, isEditing: _isEditing, onEditing: (bool value) { - if (value != null) { + setState(() { + _isEditing = value; + }); + if (!_isEditing) { setState(() { - _isEditing = value; + selected.clear(); }); - if (!_isEditing) { - setState(() { - selected.clear(); - }); - } } - }, + }, isSearching: _isSearching, showEditingButtonLeft: true, ); @@ -197,7 +194,7 @@ class TableViewScreenState extends State } Widget _buildListTile(BuildContext context, List item) { - final bool _selected = selected?.contains(item) ?? false; + final bool _selected = selected.contains(item) ?? false; CupertinoEditingAction _action; switch (sharedValue) { case 0: diff --git a/deprecated/cupertino_controllers/lib/table_view_controller/controller.dart b/deprecated/cupertino_controllers/lib/table_view_controller/controller.dart index 34ea49a..87bf119 100644 --- a/deprecated/cupertino_controllers/lib/table_view_controller/controller.dart +++ b/deprecated/cupertino_controllers/lib/table_view_controller/controller.dart @@ -138,7 +138,7 @@ class CupertinoTableViewController extends StatelessWidget { } return DefaultTextStyle( - style: Theme.of(context).textTheme.title!, + style: Theme.of(context).textTheme.titleLarge!, child: Scaffold( body: CustomScrollView( primary: true, diff --git a/deprecated/cupertino_controllers/lib/table_view_controller/templates/phone_tile.dart b/deprecated/cupertino_controllers/lib/table_view_controller/templates/phone_tile.dart index 6ea166e..be42144 100644 --- a/deprecated/cupertino_controllers/lib/table_view_controller/templates/phone_tile.dart +++ b/deprecated/cupertino_controllers/lib/table_view_controller/templates/phone_tile.dart @@ -1,5 +1,4 @@ import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import '../../widgets/text.dart'; diff --git a/deprecated/cupertino_controllers/lib/widgets/search.dart b/deprecated/cupertino_controllers/lib/widgets/search.dart index 89cec1b..3511daa 100644 --- a/deprecated/cupertino_controllers/lib/widgets/search.dart +++ b/deprecated/cupertino_controllers/lib/widgets/search.dart @@ -14,9 +14,7 @@ class CupertinoSearchBar extends AnimatedWidget { this.onClear, this.enabled = true, this.autoCorrect = true, - }) : assert(controller != null), - assert(focusNode != null), - super(key: key, listenable: animation); + }) : super(key: key, listenable: animation); final TextEditingController controller; final FocusNode focusNode; @@ -68,7 +66,7 @@ class CupertinoSearchBar extends AnimatedWidget { style: new TextStyle( inherit: false, color: CupertinoColors.inactiveGray - .withOpacity(_opacityTween.evaluate(animation)), + .withValues(alpha: _opacityTween.evaluate(animation)), fontSize: _kFontSize, ), ), @@ -102,11 +100,10 @@ class CupertinoSearchBar extends AnimatedWidget { ), ), new CupertinoButton( - minSize: 10.0, padding: const EdgeInsets.all(1.0), borderRadius: new BorderRadius.circular(30.0), - color: CupertinoColors.inactiveGray.withOpacity( - 1.0 - _opacityTween.evaluate(animation), + color: CupertinoColors.inactiveGray.withValues( + alpha: 1.0 - _opacityTween.evaluate(animation), ), child: new Icon( Icons.close, @@ -118,7 +115,7 @@ class CupertinoSearchBar extends AnimatedWidget { return; else onClear!(); - }, + }, minimumSize: Size(10.0, 10.0), ), ], ), diff --git a/deprecated/cupertino_controllers/lib/widgets/text.dart b/deprecated/cupertino_controllers/lib/widgets/text.dart index 78f02e5..07c3856 100644 --- a/deprecated/cupertino_controllers/lib/widgets/text.dart +++ b/deprecated/cupertino_controllers/lib/widgets/text.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; enum CupertinoTextTheme { title, subtitle, detail, custom } diff --git a/deprecated/dart_firebase/example/lib/main.dart b/deprecated/dart_firebase/example/lib/main.dart index 9ec0ba6..1cb4915 100644 --- a/deprecated/dart_firebase/example/lib/main.dart +++ b/deprecated/dart_firebase/example/lib/main.dart @@ -168,11 +168,6 @@ class _UsesExampleState extends State { ), body: Builder( builder: (_) { - if (_users == null) { - return Center( - child: CircularProgressIndicator(), - ); - } if (_users.isEmpty) { return Center( child: Text('No Users Found'), diff --git a/deprecated/dart_firebase/lib/src/client.dart b/deprecated/dart_firebase/lib/src/client.dart index ee3a8c0..3632774 100755 --- a/deprecated/dart_firebase/lib/src/client.dart +++ b/deprecated/dart_firebase/lib/src/client.dart @@ -49,9 +49,7 @@ class App { this.messagingSenderId, this.appId, String? database, - }) : _name = database, - assert(apiKey != null), - assert(projectId != null); + }) : _name = database; factory App.fromJson(Map json) { return App( diff --git a/deprecated/dart_firebase/lib/src/impl/browser.dart b/deprecated/dart_firebase/lib/src/impl/browser.dart index 2d6c8c5..c608e03 100755 --- a/deprecated/dart_firebase/lib/src/impl/browser.dart +++ b/deprecated/dart_firebase/lib/src/impl/browser.dart @@ -14,7 +14,7 @@ class FirestoreClientImpl extends FirestoreHttpClient { @override Future sendHttpRequest(Uri uri, - {bool needsToken: true, + {bool needsToken = true, String? extract, Map? body}) async { var request = new HttpRequest(); diff --git a/deprecated/dart_firebase/lib/src/impl/common/http.dart b/deprecated/dart_firebase/lib/src/impl/common/http.dart index de50d96..3ae3e57 100755 --- a/deprecated/dart_firebase/lib/src/impl/common/http.dart +++ b/deprecated/dart_firebase/lib/src/impl/common/http.dart @@ -26,10 +26,6 @@ abstract class FirestoreHttpClient implements FirestoreClient { FirestoreAccessToken token; bool isCurrentTokenValid(bool refreshable) { - if (token == null) { - return false; - } - if (refreshable) { var now = DateTime.now(); return token.expiresAt.difference(now).abs().inSeconds >= 60; @@ -81,13 +77,11 @@ abstract class FirestoreHttpClient implements FirestoreClient { @override CollectionReference collection(String path) { - assert(path != null); return CollectionReference(this, path.split('/')); } @override DocumentReference document(String path) { - assert(path != null); return DocumentReference(this, path.split('/')); } @@ -99,22 +93,22 @@ abstract class FirestoreHttpClient implements FirestoreClient { Future?> getJsonMap(String url, {Map? body, - String? extract: "response", - bool standard: true}) async { + String? extract = "response", + bool standard = true}) async { return (await sendHttpRequest(_apiUrl(url, standard), body: body, extract: extract)) as Map?; } Future?> getJsonList(String url, {Map? body, - String extract: "response", - bool standard: true}) async { + String extract = "response", + bool standard = true}) async { return (await sendHttpRequest(_apiUrl(url, standard), body: body, extract: extract)) as List?; } Future sendHttpRequest(Uri uri, - {bool needsToken: true, String? extract, Map? body}); + {bool needsToken = true, String? extract, Map? body}); Uri _apiUrl(String path, bool standard) { path = standard ? "$path" : path; diff --git a/deprecated/dart_firebase/lib/src/impl/io.dart b/deprecated/dart_firebase/lib/src/impl/io.dart index 8ab3a11..db6217d 100755 --- a/deprecated/dart_firebase/lib/src/impl/io.dart +++ b/deprecated/dart_firebase/lib/src/impl/io.dart @@ -27,7 +27,7 @@ class FirestoreClientImpl extends FirestoreHttpClient { @override Future sendHttpRequest(Uri uri, - {bool needsToken: true, + {bool needsToken = true, String? extract, Map? body}) async { if (endpoints.enableProxyMode) { diff --git a/deprecated/dart_firebase/lib/src/types/firestore/document_reference.dart b/deprecated/dart_firebase/lib/src/types/firestore/document_reference.dart index 2c77e8e..4027fb8 100755 --- a/deprecated/dart_firebase/lib/src/types/firestore/document_reference.dart +++ b/deprecated/dart_firebase/lib/src/types/firestore/document_reference.dart @@ -25,7 +25,6 @@ class DocumentReference implements FirestoreReference { /// Returns the reference of a collection contained inside of this /// document. CollectionReference collection(String collectionPath) { - assert(collectionPath != null); return CollectionReference(client, [path, collectionPath]); } diff --git a/deprecated/dart_firebase/lib/tool.dart b/deprecated/dart_firebase/lib/tool.dart index 93363d0..0206d34 100755 --- a/deprecated/dart_firebase/lib/tool.dart +++ b/deprecated/dart_firebase/lib/tool.dart @@ -21,10 +21,8 @@ const List _passwordEnvVars = const [ String? _getEnvKey(List possible) { for (var key in possible) { var dartEnvValue = new String.fromEnvironment(key); - if (dartEnvValue != null) { - return dartEnvValue; - } - + return dartEnvValue; + if (Platform.environment.containsKey(key) && Platform.environment[key]!.isNotEmpty) { return Platform.environment[key]; diff --git a/deprecated/dynamic_tabs/lib/data/models/tab_state.dart b/deprecated/dynamic_tabs/lib/data/models/tab_state.dart index bb05a59..0bb44fa 100644 --- a/deprecated/dynamic_tabs/lib/data/models/tab_state.dart +++ b/deprecated/dynamic_tabs/lib/data/models/tab_state.dart @@ -67,7 +67,7 @@ class TabState extends ChangeNotifier { void changeTabOrder(List _list) { List _tabs = _list; - if (_tabs != null && _tabs.isNotEmpty) { + if (_tabs.isNotEmpty) { List _newOrder = []; for (var item in _tabs) { _newOrder.add(_items!.firstWhere((t) => t.tag == item)); @@ -92,14 +92,12 @@ class TabState extends ChangeNotifier { void _loadIndex() { if (_persistIndex) { int _index = _storage.getInt(navKey); - if (_index != null) { - if (_index > _maxTabs) { - _index = 0; - } - _currentIndex = _index; - notifyListeners(); + if (_index > _maxTabs) { + _index = 0; } - _saveIndex(); + _currentIndex = _index; + notifyListeners(); + _saveIndex(); } } diff --git a/deprecated/dynamic_tabs/lib/ui/common/grid_item.dart b/deprecated/dynamic_tabs/lib/ui/common/grid_item.dart index d5e6acc..ca2280b 100644 --- a/deprecated/dynamic_tabs/lib/ui/common/grid_item.dart +++ b/deprecated/dynamic_tabs/lib/ui/common/grid_item.dart @@ -28,7 +28,7 @@ class GridTabItem extends StatelessWidget { feedback: DefaultTextStyle( style: adaptive && defaultTargetPlatform == TargetPlatform.iOS ? CupertinoTheme.of(context).textTheme.textStyle - : Theme.of(context).textTheme.title!, + : Theme.of(context).textTheme.titleLarge!, child: Container( width: 120.0, height: 80.0, diff --git a/deprecated/dynamic_tabs/lib/ui/edit_screen.dart b/deprecated/dynamic_tabs/lib/ui/edit_screen.dart index 877c941..a23607f 100644 --- a/deprecated/dynamic_tabs/lib/ui/edit_screen.dart +++ b/deprecated/dynamic_tabs/lib/ui/edit_screen.dart @@ -70,7 +70,7 @@ class _EditScreenState extends State { )); } return DefaultTextStyle( - style: Theme.of(context).textTheme.display1!, + style: Theme.of(context).textTheme.headlineMedium!, child: Scaffold( appBar: AppBar( actions: [ @@ -118,7 +118,7 @@ class _EditScreenState extends State { "Drag the icons to\norganize tabs.", style: Theme.of(context) .textTheme - .headline4! + .headlineMedium! .copyWith(fontSize: 22.0), textAlign: TextAlign.center, ), @@ -197,7 +197,7 @@ class _BottomEditableTabBarState extends State { // draggable: true, ); }, - onWillAccept: (String? data) { + onWillAcceptWithDetails: (String? data) { setState(() { _previewIndex = _targets.indexOf(t); }); @@ -208,7 +208,7 @@ class _BottomEditableTabBarState extends State { _previewIndex = null; }); }, - onAccept: (String data) { + onAcceptWithDetails: (String data) { final DynamicTab _baseTab = _targets[_previewIndex!]; final DynamicTab _newTab = _tabs!.firstWhere((t) => t.tag == data); final int _oldIndex = _tabs!.indexOf(_newTab); @@ -232,7 +232,7 @@ class _BottomEditableTabBarState extends State { child: Container(), tab: BottomNavigationBarItem( icon: Icon(Icons.more_horiz), - title: Text("More"), + label: Text("More"), ), tag: "", ), diff --git a/deprecated/dynamic_tabs/lib/ui/more_screen.dart b/deprecated/dynamic_tabs/lib/ui/more_screen.dart index 24ffdb8..0368d75 100644 --- a/deprecated/dynamic_tabs/lib/ui/more_screen.dart +++ b/deprecated/dynamic_tabs/lib/ui/more_screen.dart @@ -183,7 +183,7 @@ class MaterialPage extends StatelessWidget { final i = model.extraTabs[index]; return ListTile( leading: i.tab.icon, - title: i.tab.title, + title: i.tab.label, selected: expanded ? index == model.subIndex : false, trailing: !expanded ? Icon(Icons.keyboard_arrow_right) : null, @@ -245,7 +245,7 @@ class CupertinoPage extends StatelessWidget { (BuildContext context, int index) { final i = model.extraTabs[index]; final Icon _icon = i.tab.icon as Icon; - final Text _text = i.tab.title as Text; + final Text _text = i.tab.label as Text; return DefaultTextStyle( style: CupertinoTheme.of(context).textTheme.textStyle, child: CupertinoListTile( diff --git a/deprecated/easy_google_maps/lib/easy_google_maps.dart b/deprecated/easy_google_maps/lib/easy_google_maps.dart index aecef92..49fc24f 100644 --- a/deprecated/easy_google_maps/lib/easy_google_maps.dart +++ b/deprecated/easy_google_maps/lib/easy_google_maps.dart @@ -63,19 +63,19 @@ class _EasyGoogleMapsState extends State { return EasyWebView( src: _src, webAllowFullScreen: true, - width: widget?.width, - height: widget?.height, + width: widget.width, + height: widget.height, ); } return SizedBox( - width: widget?.width, - height: widget?.height, + width: widget.width, + height: widget.height, child: FutureBuilder>( future: geo.placemarkFromAddress(widget.address), builder: (_, snapshot) { if (snapshot.hasData) { - final _place = snapshot?.data?.first; + final _place = snapshot.data?.first; if (_place == null) { return Center( child: Text('Address not found!'), @@ -89,7 +89,7 @@ class _EasyGoogleMapsState extends State { markerId: MarkerId(widget.address.toString()), position: _latLang, infoWindow: InfoWindow( - title: widget?.title ?? '', + title: widget.title ?? '', snippet: widget.address, ), ); diff --git a/deprecated/easy_web_view/example/lib/examples/basic.dart b/deprecated/easy_web_view/example/lib/examples/basic.dart index 78acb2a..f2cbf85 100644 --- a/deprecated/easy_web_view/example/lib/examples/basic.dart +++ b/deprecated/easy_web_view/example/lib/examples/basic.dart @@ -2,7 +2,7 @@ import 'package:easy_web_view/easy_web_view.dart'; import 'package:flutter/material.dart'; class BasicExample extends StatefulWidget { - const BasicExample({Key? key}) : super(key: key); + const BasicExample({super.key}); @override _BasicExampleState createState() => _BasicExampleState(); diff --git a/deprecated/easy_web_view/example/lib/examples/html_to_pdf.dart b/deprecated/easy_web_view/example/lib/examples/html_to_pdf.dart index 14cf872..24fc36a 100644 --- a/deprecated/easy_web_view/example/lib/examples/html_to_pdf.dart +++ b/deprecated/easy_web_view/example/lib/examples/html_to_pdf.dart @@ -10,7 +10,7 @@ import 'package:async/async.dart'; import 'package:flutter/services.dart'; class HtmlToPdfTest extends StatefulWidget { - const HtmlToPdfTest({Key? key}) : super(key: key); + const HtmlToPdfTest({super.key}); @override State createState() => _HtmlToPdfTestState(); diff --git a/deprecated/easy_web_view/example/lib/main.dart b/deprecated/easy_web_view/example/lib/main.dart index 7101ff6..e18b215 100644 --- a/deprecated/easy_web_view/example/lib/main.dart +++ b/deprecated/easy_web_view/example/lib/main.dart @@ -6,7 +6,7 @@ import 'examples/html_to_pdf.dart'; void main() => runApp(const MyApp()); class MyApp extends StatefulWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override State createState() => _MyAppState(); diff --git a/deprecated/fb_auth/example/lib/main.dart b/deprecated/fb_auth/example/lib/main.dart index 1c2a8f5..21a704a 100644 --- a/deprecated/fb_auth/example/lib/main.dart +++ b/deprecated/fb_auth/example/lib/main.dart @@ -35,7 +35,7 @@ class _MyAppState extends State { @override void dispose() { _auth.close(); - _userChanged?.cancel(); + _userChanged.cancel(); super.dispose(); } diff --git a/deprecated/fb_auth/example/lib/plugins/desktop/io.dart b/deprecated/fb_auth/example/lib/plugins/desktop/io.dart index dc96e0e..44b5354 100644 --- a/deprecated/fb_auth/example/lib/plugins/desktop/io.dart +++ b/deprecated/fb_auth/example/lib/plugins/desktop/io.dart @@ -1,19 +1,8 @@ -import 'dart:io'; import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; void setTargetPlatformForDesktop({TargetPlatform platform}) { TargetPlatform targetPlatform; - if (platform != null) { - targetPlatform = platform; - } - if (targetPlatform == null) { - if (Platform.isMacOS) { - targetPlatform = TargetPlatform.iOS; - } else if (Platform.isLinux || Platform.isWindows) { - targetPlatform = TargetPlatform.android; - } - } + targetPlatform = platform; debugDefaultTargetPlatformOverride = targetPlatform; } diff --git a/deprecated/fb_auth/lib/data/blocs/auth/auth_bloc.dart b/deprecated/fb_auth/lib/data/blocs/auth/auth_bloc.dart index 0ef6c1a..069a168 100644 --- a/deprecated/fb_auth/lib/data/blocs/auth/auth_bloc.dart +++ b/deprecated/fb_auth/lib/data/blocs/auth/auth_bloc.dart @@ -72,7 +72,7 @@ class AuthBloc extends Bloc { final _user = await _auth.loginGoogle( idToken: event.idToken, accessToken: event.accessToken); if (_user != null) { - if (saveUser != null) saveUser(_user); + saveUser(_user); yield LoggedInState(_user); } else { yield LoggedOutState(); @@ -82,37 +82,25 @@ class AuthBloc extends Bloc { Stream _mapGuestToState(LoginGuest event) async* { yield AuthLoadingState(); final _user = await _auth.startAsGuest(); - if (_user != null) { - if (saveUser != null) saveUser(_user); - yield LoggedInState(_user); - } else { - yield LoggedOutState(); + saveUser(_user); + yield LoggedInState(_user); } - } Stream _mapCheckToState(CheckUser event) async* { yield AuthLoadingState(); final _user = await _auth.currentUser(); - if (_user != null) { - if (saveUser != null) saveUser(_user); - yield LoggedInState(_user); - } else { - yield LoggedOutState(); + saveUser(_user); + yield LoggedInState(_user); } - } Stream _mapCreateToState(CreateAccount event) async* { yield AuthLoadingState(); try { AuthUser _user = await _auth.createAccount(event.username, event.password, - displayName: event?.displayName, photoUrl: event?.photoUrl); - if (_user != null) { - if (saveUser != null) saveUser(_user); - yield LoggedInState(_user); - } else { - yield AuthErrorState('Error creating user!'); - } - } catch (e) { + displayName: event.displayName, photoUrl: event.photoUrl); + saveUser(_user); + yield LoggedInState(_user); + } catch (e) { yield AuthErrorState('Email already exists!'); } } @@ -120,18 +108,14 @@ class AuthBloc extends Bloc { Stream _mapLoginToState(LoginEvent event) async* { yield AuthLoadingState(); final _user = await _auth.login(event.username, event.password); - if (_user != null) { - if (saveUser != null) saveUser(_user); - yield LoggedInState(_user); - } else { - yield AuthErrorState('Username or Password Incorrect!'); + saveUser(_user); + yield LoggedInState(_user); } - } Stream _mapLogoutToState(LogoutEvent event) async* { yield AuthLoadingState(); await _auth.logout(); - if (deleteUser != null) deleteUser(); + deleteUser(); yield LoggedOutState(); } @@ -142,20 +126,16 @@ class AuthBloc extends Bloc { Stream _mapEditInfoToState(EditInfo event) async* { yield AuthLoadingState(); await _auth.editInfo( - displayName: event?.displayName, photoUrl: event?.photoUrl); + displayName: event.displayName, photoUrl: event.photoUrl); final _user = await _auth.currentUser(); - if (saveUser != null) saveUser(_user); + saveUser(_user); yield LoggedInState(_user); } Stream _mapUpdateToState(UpdateUser event) async* { - if (event?.user != null) { - if (saveUser != null) saveUser(event.user); - yield LoggedInState(event.user); - } else { - yield LoggedOutState(); + saveUser(event.user); + yield LoggedInState(event.user); } - } Stream _mapForgotPasswordToState(ForgotPassword event) async* { await _auth.forgotPassword(event.email); diff --git a/deprecated/fb_auth/lib/data/services/auth/io.dart b/deprecated/fb_auth/lib/data/services/auth/io.dart index ef53b34..2623854 100644 --- a/deprecated/fb_auth/lib/data/services/auth/io.dart +++ b/deprecated/fb_auth/lib/data/services/auth/io.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:io'; import '../../classes/index.dart'; -import '../../utils/directory.dart'; import '../mobile/sdk.dart'; import '../rest_api/client.dart'; import 'impl.dart'; @@ -35,12 +34,8 @@ class FBAuth implements FBAuthImpl { }, onSave: (data) async { try { - if (data == null) { - await _saveFile.delete(); - } else { - await _saveFile.writeAsString(json.encode(data)); - } - } catch (e) {} + await _saveFile.writeAsString(json.encode(data)); + } catch (e) {} }, ); } @@ -50,10 +45,7 @@ class FBAuth implements FBAuthImpl { } Future _loadFile() async { - if (_saveFile == null) { - final dir = await PathUtils.getDocumentDir(); - _saveFile = File('${dir.path}/fb_auth.json'); - } + } bool get useClient => isDesktop || useRestClient; diff --git a/deprecated/fb_auth/lib/data/services/auth/web.dart b/deprecated/fb_auth/lib/data/services/auth/web.dart index e823865..bd511c1 100644 --- a/deprecated/fb_auth/lib/data/services/auth/web.dart +++ b/deprecated/fb_auth/lib/data/services/auth/web.dart @@ -115,8 +115,8 @@ class FBAuth implements FBAuthImpl { Future editInfo({String displayName, String photoUrl}) async { final _user = _auth.currentUser; final _info = UserProfile(); - if (displayName != null) _info.displayName = displayName; - if (photoUrl != null) _info.photoURL = photoUrl; + _info.displayName = displayName; + _info.photoURL = photoUrl; try { await _user.updateProfile(_info); } catch (e) { diff --git a/deprecated/fb_auth/lib/data/services/mobile/sdk.dart b/deprecated/fb_auth/lib/data/services/mobile/sdk.dart index 7db7288..6f0912d 100644 --- a/deprecated/fb_auth/lib/data/services/mobile/sdk.dart +++ b/deprecated/fb_auth/lib/data/services/mobile/sdk.dart @@ -94,8 +94,8 @@ class FbSdk implements FBAuthImpl { Future editInfo({String displayName, String photoUrl}) async { final _user = await _auth.currentUser(); final _info = UserUpdateInfo(); - if (displayName != null) _info.displayName = displayName; - if (photoUrl != null) _info.photoUrl = photoUrl; + _info.displayName = displayName; + _info.photoUrl = photoUrl; try { await _user.updateProfile(_info); } catch (e) { diff --git a/deprecated/fb_auth/lib/data/services/rest_api/client.dart b/deprecated/fb_auth/lib/data/services/rest_api/client.dart index af7371f..f370e99 100644 --- a/deprecated/fb_auth/lib/data/services/rest_api/client.dart +++ b/deprecated/fb_auth/lib/data/services/rest_api/client.dart @@ -43,18 +43,16 @@ class FbClient implements FBAuthImpl { @override Future currentUser() async { FirestoreJsonAccessToken token = await _loadToken(); - if (token != null) { - var result = await http.post( - 'https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=${app.apiKey}', - body: json.encode({ - "idToken": token?.idToken, - "returnSecureToken": true, - }), - ); - token = await _saveToken(result); - return _getUser(token); - } - return null; + var result = await http.post( + 'https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=${app.apiKey}', + body: json.encode({ + "idToken": token.idToken, + "returnSecureToken": true, + }), + ); + token = await _saveToken(result); + return _getUser(token); + return null; } @override @@ -63,16 +61,15 @@ class FbClient implements FBAuthImpl { final result = await http.post( 'https://identitytoolkit.googleapis.com/v1/accounts:update?key=${app.apiKey}', body: json.encode({ - "idToken": token?.idToken, - if (displayName != null) ...{ - 'displayName': displayName, - }, - if (photoUrl != null) ...{ - 'photoUrl': photoUrl, - }, + "idToken": token.idToken, + ...{ + 'displayName': displayName, + }, + ...{ + 'photoUrl': photoUrl, + }, "deleteAttribute": [ - if (displayName == null) 'DISPLAY_NAME', - if (photoUrl == null) 'PHOTO_URL', + ], "returnSecureToken": true, }), @@ -126,7 +123,7 @@ class FbClient implements FBAuthImpl { var result = await http.post( 'https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${app.apiKey}', body: json.encode({ - "idToken": token?.idToken, + "idToken": token.idToken, "requestType": 'VERIFY_EMAIL', }), ); @@ -169,12 +166,12 @@ class FbClient implements FBAuthImpl { final _user = FirebaseUser(item, token.idToken); if (_user.uid == token.localId) { final _auth = AuthUser( - displayName: _user?.displayName, - email: _user?.email, - isAnonymous: _user?.isAnonymous ?? true, - isEmailVerified: _user?.isEmailVerified ?? false, + displayName: _user.displayName, + email: _user.email, + isAnonymous: _user.isAnonymous ?? true, + isEmailVerified: _user.isEmailVerified ?? false, photoUrl: _user.photoUrl, - uid: _user?.uid, + uid: _user.uid, ); _onAuthChanged.add(_auth); return _auth; @@ -185,11 +182,9 @@ class FbClient implements FBAuthImpl { Future _loadToken() async { final _data = await onLoad(); - if (_data != null) { - final token = FirestoreJsonAccessToken(_data, DateTime.now()); - return token; - } - return null; + final token = FirestoreJsonAccessToken(_data, DateTime.now()); + return token; + return null; } @override diff --git a/deprecated/fb_auth/lib/data/services/rest_api/helpers/user.dart b/deprecated/fb_auth/lib/data/services/rest_api/helpers/user.dart index 7871b18..94c5e2d 100644 --- a/deprecated/fb_auth/lib/data/services/rest_api/helpers/user.dart +++ b/deprecated/fb_auth/lib/data/services/rest_api/helpers/user.dart @@ -24,7 +24,7 @@ class FirebaseUser { }).toList(); } - bool get isAnonymous => email == null || email.isEmpty; + bool get isAnonymous => email.isEmpty; bool get isEmailVerified => json['emailVerified']; diff --git a/deprecated/fb_firestore/example/lib/main.dart b/deprecated/fb_firestore/example/lib/main.dart index a5e2e56..48d955c 100644 --- a/deprecated/fb_firestore/example/lib/main.dart +++ b/deprecated/fb_firestore/example/lib/main.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; -import 'dart:async'; -import 'package:flutter/services.dart'; import 'package:fb_firestore/fb_firestore.dart'; void main() => runApp(MyApp()); diff --git a/deprecated/features/example/lib/main.dart b/deprecated/features/example/lib/main.dart index 8e22ac5..dcb6cef 100644 --- a/deprecated/features/example/lib/main.dart +++ b/deprecated/features/example/lib/main.dart @@ -77,7 +77,7 @@ class _MyHomePageState extends State { ), Text( '$_counter', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), FeatureBuilder( feature: _counterFeature, diff --git a/deprecated/file_access/lib/src/pick_file/io.dart b/deprecated/file_access/lib/src/pick_file/io.dart index 0a5d4a2..1e85931 100644 --- a/deprecated/file_access/lib/src/pick_file/io.dart +++ b/deprecated/file_access/lib/src/pick_file/io.dart @@ -9,13 +9,11 @@ import 'package:image_picker/image_picker.dart'; Future openFile() async { final _files = await _open(false, false); - if (_files == null) return null; return _files.first; } Future> openFiles() async { final _files = await _open(true, false); - if (_files == null) return null; return _files; } @@ -30,7 +28,7 @@ Future pickImage() async { fileExtensions: kImageExtensions, ), ]); - if (_files == null || _files.isEmpty) return null; + if (_files.isEmpty) return null; return _files.first; } @@ -45,7 +43,7 @@ Future pickVideo() async { fileExtensions: kVideoExtensions, ), ]); - if (_files == null || _files.isEmpty) return null; + if (_files.isEmpty) return null; return _files.first; } @@ -68,13 +66,11 @@ Future> _open(bool multiple, bool folders, final List _files = []; if (multiple) { List files = await FilePicker.getMultiFile(); - if (files == null) return null; for (final file in files) { _files.add(await _add(file)); } } else { File file = await FilePicker.getFile(); - if (file == null) return null; _files.add(await _add(file)); } return _files; diff --git a/deprecated/file_access/lib/src/pick_file/web.dart b/deprecated/file_access/lib/src/pick_file/web.dart index 795b145..155ce9e 100644 --- a/deprecated/file_access/lib/src/pick_file/web.dart +++ b/deprecated/file_access/lib/src/pick_file/web.dart @@ -6,31 +6,30 @@ import 'dart:html' as html; Future pickImage() async { final _files = await _open(false, false, 'image/*'); - if (_files == null || _files.isEmpty) return null; + if (_files.isEmpty) return null; return _files.first; } Future pickVideo() async { final _files = await _open(false, false, 'video/*'); - if (_files == null || _files.isEmpty) return null; + if (_files.isEmpty) return null; return _files.first; } Future pickAudio() async { final _files = await _open(false, false, 'audio/*'); - if (_files == null || _files.isEmpty) return null; + if (_files.isEmpty) return null; return _files.first; } Future openFile() async { final _files = await _open(false, false); - if (_files == null || _files.isEmpty) return null; + if (_files.isEmpty) return null; return _files.first; } Future> openFiles() async { final _files = await _open(true, false); - if (_files == null) return null; return _files; } @@ -46,7 +45,6 @@ Future> _open(bool multiple, bool folders, } _upload.click(); final _file = await _upload.onChange.first; - if (_file == null) return null; List files = (_file.target as dynamic).files; final List _files = []; for (final f in files) { diff --git a/deprecated/floating_search_bar/example/lib/main.dart b/deprecated/floating_search_bar/example/lib/main.dart index df299cb..4354e82 100644 --- a/deprecated/floating_search_bar/example/lib/main.dart +++ b/deprecated/floating_search_bar/example/lib/main.dart @@ -25,9 +25,7 @@ void _setTargetPlatformForDesktop() { } else if (Platform.isLinux || Platform.isWindows) { targetPlatform = TargetPlatform.android; } - if (targetPlatform != null) { - debugDefaultTargetPlatformOverride = targetPlatform; - } + debugDefaultTargetPlatformOverride = targetPlatform; } class MyApp extends StatefulWidget { diff --git a/deprecated/floating_search_bar/lib/ui/sliver_search_bar.dart b/deprecated/floating_search_bar/lib/ui/sliver_search_bar.dart index 7d95847..60b8862 100644 --- a/deprecated/floating_search_bar/lib/ui/sliver_search_bar.dart +++ b/deprecated/floating_search_bar/lib/ui/sliver_search_bar.dart @@ -19,11 +19,7 @@ class SliverFloatingBar extends StatefulWidget { this.floating = false, this.pinned = false, this.snap = false, - }) : assert(automaticallyImplyLeading != null), - assert(floating != null), - assert(pinned != null), - assert(snap != null), - assert(floating || !snap, + }) : assert(floating || !snap, 'The "snap" argument only makes sense for floating app bars.'), super(key: key); @@ -224,35 +220,28 @@ class _FloatingAppBarState extends State<_FloatingAppBar> { @override void didChangeDependencies() { super.didChangeDependencies(); - if (_position != null) - _position.isScrollingNotifier.removeListener(_isScrollingListener); - _position = Scrollable.of(context)?.position; - if (_position != null) - _position.isScrollingNotifier.addListener(_isScrollingListener); + _position.isScrollingNotifier.removeListener(_isScrollingListener); + _position = Scrollable.of(context).position; + _position.isScrollingNotifier.addListener(_isScrollingListener); } @override void dispose() { - if (_position != null) - _position.isScrollingNotifier.removeListener(_isScrollingListener); + _position.isScrollingNotifier.removeListener(_isScrollingListener); super.dispose(); } RenderSliverFloatingPersistentHeader _headerRenderer() { - return context.ancestorRenderObjectOfType( - const TypeMatcher()); + return context.findAncestorRenderObjectOfType( + ); } void _isScrollingListener() { - if (_position == null) return; - - // When a scroll stops, then maybe snap the appbar into view. - // Similarly, when a scroll starts, then maybe stop the snap animation. final RenderSliverFloatingPersistentHeader header = _headerRenderer(); if (_position.isScrollingNotifier.value) - header?.maybeStopSnapAnimation(_position.userScrollDirection); + header.maybeStopSnapAnimation(_position.userScrollDirection); else - header?.maybeStartSnapAnimation(_position.userScrollDirection); + header.maybeStartSnapAnimation(_position.userScrollDirection); } @override diff --git a/deprecated/flutter_ast/lib/cli/generator.dart b/deprecated/flutter_ast/lib/cli/generator.dart index 38ff808..1509421 100644 --- a/deprecated/flutter_ast/lib/cli/generator.dart +++ b/deprecated/flutter_ast/lib/cli/generator.dart @@ -132,7 +132,6 @@ void _processFile( if (item.isValid) { if (!cache.addName(item.name)) continue; final _template = _processClass(item, input); - if (_template == null) continue; final name = ReCase(item.name).snakeCase; final _path = 'classes/' + name + '.dart'; final _file = _getFile(output.path, _path); diff --git a/deprecated/flutter_ast/lib/flutter_ast.dart b/deprecated/flutter_ast/lib/flutter_ast.dart index 1fd1f42..36fbec1 100644 --- a/deprecated/flutter_ast/lib/flutter_ast.dart +++ b/deprecated/flutter_ast/lib/flutter_ast.dart @@ -6,7 +6,7 @@ import 'src/index.dart'; export 'src/index.dart'; DartResult parseSource(String source, [String path]) { - assert(source != null && source.isNotEmpty); + assert(source.isNotEmpty); final result = parseString( content: source, path: path, diff --git a/deprecated/flutter_ast/lib/src/class.dart b/deprecated/flutter_ast/lib/src/class.dart index 98c2882..fda00a5 100644 --- a/deprecated/flutter_ast/lib/src/class.dart +++ b/deprecated/flutter_ast/lib/src/class.dart @@ -25,10 +25,10 @@ extension ClauseDeclarationImplUtils on ClassDeclarationImpl { comments.add(item.toDartComment()); } return base.copyWith( - isAbstract: this?.abstractKeyword != null, - extendsClause: this?.extendsClause?.toString(), - implementsClause: this?.implementsClause?.toString(), - withClause: this?.withClause?.toString(), + isAbstract: this.abstractKeyword != null, + extendsClause: this.extendsClause?.toString(), + implementsClause: this.implementsClause?.toString(), + withClause: this.withClause?.toString(), fields: fields, constructors: constructors, methods: methods, diff --git a/deprecated/flutter_ast/lib/src/field.dart b/deprecated/flutter_ast/lib/src/field.dart index da831d7..0cb4fa6 100644 --- a/deprecated/flutter_ast/lib/src/field.dart +++ b/deprecated/flutter_ast/lib/src/field.dart @@ -51,12 +51,11 @@ extension DefaultFormalParameterImplUtils on DefaultFormalParameterImpl { base = base.copyWith(name: child.toString()); } } - if (fields != null) - for (final field in fields) { - if (field.name == base.name) { - base = base.copyWith(type: field.type); - } + for (final field in fields) { + if (field.name == base.name) { + base = base.copyWith(type: field.type); } + } } if (node.runtimeType.toString() == 'SimpleToken' && node.toString() == '=') { diff --git a/deprecated/flutter_ast/lib/src/generator/parser.dart b/deprecated/flutter_ast/lib/src/generator/parser.dart index 078520a..0857bef 100644 --- a/deprecated/flutter_ast/lib/src/generator/parser.dart +++ b/deprecated/flutter_ast/lib/src/generator/parser.dart @@ -38,22 +38,22 @@ class GenParser { void merge(String source) { final DartResult result = parseSource(source); - if (result?.file != null) { - if (result?.file?.classes != null) { + if (result.file != null) { + if (result.file?.classes != null) { for (final item in result.file.classes) { this._classes.putIfAbsent(item.name, () => item); } } - if (result?.file?.enums != null) { + if (result.file?.enums != null) { this._enums.addAll(result.file.enums); } - if (result?.file?.fields != null) { + if (result.file?.fields != null) { this._fields.addAll(result.file.fields); } - if (result?.file?.methods != null) { + if (result.file?.methods != null) { this._methods.addAll(result.file.methods); } - if (result?.file?.imports != null) { + if (result.file?.imports != null) { this._imports.addAll(result.file.imports); } } diff --git a/deprecated/flutter_cli/lib/src/commands/command.dart b/deprecated/flutter_cli/lib/src/commands/command.dart index 3e03968..2efd472 100644 --- a/deprecated/flutter_cli/lib/src/commands/command.dart +++ b/deprecated/flutter_cli/lib/src/commands/command.dart @@ -18,7 +18,7 @@ abstract class NgDartCommand extends Command { String readArg(String errorMessage) { var args = argResults.rest; - if (args == null || args.length == 0) { + if (args.length == 0) { // Usage is provided by command runner. throw new UsageException(errorMessage, ''); } diff --git a/deprecated/flutter_cli/lib/src/file_reader.dart b/deprecated/flutter_cli/lib/src/file_reader.dart index a08f04a..59892b6 100644 --- a/deprecated/flutter_cli/lib/src/file_reader.dart +++ b/deprecated/flutter_cli/lib/src/file_reader.dart @@ -12,9 +12,9 @@ class FileReader { FileReader._(); - String readAsString(String filePath, {Encoding encoding: utf8}) => + String readAsString(String filePath, {Encoding encoding = utf8}) => new File(filePath).readAsStringSync(encoding: encoding); - List readAsLines(String filePath, {Encoding encoding: utf8}) => + List readAsLines(String filePath, {Encoding encoding = utf8}) => new File(filePath).readAsLinesSync(encoding: encoding); } diff --git a/deprecated/flutter_cli/lib/src/package_uri_resolver.dart b/deprecated/flutter_cli/lib/src/package_uri_resolver.dart index 752bbcb..6cdaca7 100644 --- a/deprecated/flutter_cli/lib/src/package_uri_resolver.dart +++ b/deprecated/flutter_cli/lib/src/package_uri_resolver.dart @@ -42,8 +42,6 @@ class PackageUriResolver { /// Resolves a package URI to a file path. String resolve(String packageUri) { - if (_packageMap == null) _buildPackageMap(); - var packageName = getPackageName(packageUri); if (_packageMap[packageName] == null) { diff --git a/deprecated/flutter_cli/lib/src/page_object_data.dart b/deprecated/flutter_cli/lib/src/page_object_data.dart index af0c370..e5ae51e 100644 --- a/deprecated/flutter_cli/lib/src/page_object_data.dart +++ b/deprecated/flutter_cli/lib/src/page_object_data.dart @@ -81,7 +81,7 @@ class _Selector { return new _Selector('ByTagName', element.localName); } - _Selector(this.type, this.name, [this.value]); + _Selector(this.type, this.name); @override String toString() => "@$type('${value ?? name}')"; @@ -99,9 +99,6 @@ class _Variable implements Comparable<_Variable> { factory _Variable.fromElement(Element element) { var selector = new _Selector.fromElement(element); - if (selector == null) { - return null; - } var type = new DartClassInfo( 'PageLoaderElement', 'package:pageloader/objects.dart'); diff --git a/deprecated/flutter_cli/lib/src/project_model.dart b/deprecated/flutter_cli/lib/src/project_model.dart index 9794746..0bd7ba1 100644 --- a/deprecated/flutter_cli/lib/src/project_model.dart +++ b/deprecated/flutter_cli/lib/src/project_model.dart @@ -49,7 +49,7 @@ class ProjectModel { this.componentClassUri, this.dartClasses, this.components, this.modules); /// Whether providers are needed when generating test. - bool get needProviders => serviceClasses != null && serviceClasses.isNotEmpty; + bool get needProviders => serviceClasses.isNotEmpty; /// Uris for service classes used. List get referencedUris => serviceClasses @@ -84,10 +84,6 @@ class ProjectModel { file, out, asts.publicUris, _getBindingVariables(components)))); var componentClassName = className; - if (componentClassName == null) { - componentClassName = - _getComponentClassName(componentClassUri, components); - } var serviceClasses = _getServiceClasses( componentClassName, dartClasses, components, modules); @@ -125,8 +121,6 @@ Set _getBindingVariables(Map components) { var result = new Set(); for (var component in components.values) { - if (component.module == null) continue; - for (var binding in component.module.directChildren) { if (binding is String) result.add(binding); } @@ -159,17 +153,14 @@ List _getServiceClasses( var dependencies = []; for (var parameter in dartClasses[componentClassName].constructorParameters) { var service = parameter.dependency; - if (dartClasses[service].uri == null) continue; dependencies.add(service); } var module = components[componentClassName].module; - if (module != null) { - for (var binding in module.getAllBindingInstances(modules)) { - if (dependencies.contains(binding.className)) { - dependencies.remove(binding.className); - } + for (var binding in module.getAllBindingInstances(modules)) { + if (dependencies.contains(binding.className)) { + dependencies.remove(binding.className); } } diff --git a/deprecated/flutter_cli/lib/src/visitors/binding_helper.dart b/deprecated/flutter_cli/lib/src/visitors/binding_helper.dart index 3bcf2e4..579d509 100644 --- a/deprecated/flutter_cli/lib/src/visitors/binding_helper.dart +++ b/deprecated/flutter_cli/lib/src/visitors/binding_helper.dart @@ -56,7 +56,7 @@ void processBindingElement(Expression node, ModuleInfo module) { throw new UnsupportedError('Unable to handle $node.'); } - if (binding != null) module.directChildren.add(binding); + module.directChildren.add(binding); } /// Extracts binding information from instance creation expression [node]. @@ -107,10 +107,8 @@ BindingInstance _buildBindingInstance( binding = new BindingInstance(token.value, creationExpression); } - if (binding != null) { - _handleBindingArgs(args, binding); - return binding; - } + _handleBindingArgs(args, binding); + return binding; throw new UnsupportedError('Unable to handle $token ' '(${token.runtimeType}) in $creationExpression'); diff --git a/deprecated/flutter_cli/lib/src/visitors/binding_info.dart b/deprecated/flutter_cli/lib/src/visitors/binding_info.dart index 39d8cfd..642d5ac 100644 --- a/deprecated/flutter_cli/lib/src/visitors/binding_info.dart +++ b/deprecated/flutter_cli/lib/src/visitors/binding_info.dart @@ -53,10 +53,8 @@ class ModuleInfo extends BindingInfo { /// Expands binding information in this module. List getAllBindingInstances( Map allModules) { - if (_allBindingInstances != null) { - return _allBindingInstances; - } - + return _allBindingInstances; + _allBindingInstances = []; for (var binding in directChildren) { diff --git a/deprecated/flutter_cli/lib/src/visitors/dart_class_visitor.dart b/deprecated/flutter_cli/lib/src/visitors/dart_class_visitor.dart index c767959..b5d501f 100644 --- a/deprecated/flutter_cli/lib/src/visitors/dart_class_visitor.dart +++ b/deprecated/flutter_cli/lib/src/visitors/dart_class_visitor.dart @@ -51,7 +51,7 @@ class DartClassVisitor extends RecursiveAstVisitor { var classInfo = _getClass(className(classDeclaration)); // Only first appeared class is used to get more accurate matching. - if (classInfo.uri != null) return; + return; classInfo.uri = _publicUris[_uri]; diff --git a/deprecated/flutter_cli/test/ast_cache_test.dart b/deprecated/flutter_cli/test/ast_cache_test.dart index 39b4ee7..64c3b1b 100644 --- a/deprecated/flutter_cli/test/ast_cache_test.dart +++ b/deprecated/flutter_cli/test/ast_cache_test.dart @@ -97,13 +97,13 @@ var _dotPackages = ['a:a/lib/', 'b:b/lib/']; class FileReaderMock implements FileReader { @override - List readAsLines(String filePath, {Encoding encoding: utf8}) { + List readAsLines(String filePath, {Encoding encoding = utf8}) { if (filePath == '.packages') return _dotPackages; return null; } @override - String readAsString(String filePath, {Encoding encoding: utf8}) { + String readAsString(String filePath, {Encoding encoding = utf8}) { for (var file in _files) { if (file['path'] == filePath) return file['content']; } diff --git a/deprecated/flutter_cli/test/generate_test_test.dart b/deprecated/flutter_cli/test/generate_test_test.dart index 522fdde..f513f56 100644 --- a/deprecated/flutter_cli/test/generate_test_test.dart +++ b/deprecated/flutter_cli/test/generate_test_test.dart @@ -101,7 +101,7 @@ var _pubSpec = ['name: hello_flutter']; class FileReaderMock implements FileReader { @override - List readAsLines(String filePath, {Encoding encoding: utf8}) { + List readAsLines(String filePath, {Encoding encoding = utf8}) { if (filePath == '.packages') { return _dotPackages; } else if (filePath == 'pubspec.yaml') { @@ -111,7 +111,7 @@ class FileReaderMock implements FileReader { } @override - String readAsString(String filePath, {Encoding encoding: utf8}) { + String readAsString(String filePath, {Encoding encoding = utf8}) { for (var file in _files) { if (file['path'] == filePath) return file['content']; } diff --git a/deprecated/flutter_cli/test/package_uri_resolver_test.dart b/deprecated/flutter_cli/test/package_uri_resolver_test.dart index 0cf7685..0b62122 100644 --- a/deprecated/flutter_cli/test/package_uri_resolver_test.dart +++ b/deprecated/flutter_cli/test/package_uri_resolver_test.dart @@ -60,11 +60,11 @@ class FileReaderMock implements FileReader { ]; @override - List readAsLines(Object uri, {Encoding encoding: utf8}) { + List readAsLines(Object uri, {Encoding encoding = utf8}) { if (uri is String && uri == '.packages') return _dotPackages; return null; } @override - String readAsString(Object uri, {Encoding encoding: utf8}) => null; + String readAsString(Object uri, {Encoding encoding = utf8}) => null; } diff --git a/deprecated/flutter_cli/test/project_model_test.dart b/deprecated/flutter_cli/test/project_model_test.dart index 7af23bd..25e10c8 100644 --- a/deprecated/flutter_cli/test/project_model_test.dart +++ b/deprecated/flutter_cli/test/project_model_test.dart @@ -108,7 +108,7 @@ var _pubSpec = ['name: a']; class FileReaderMock implements FileReader { @override - List readAsLines(String filePath, {Encoding encoding: utf8}) { + List readAsLines(String filePath, {Encoding encoding = utf8}) { if (filePath == '.packages') { return _dotPackages; } else if (filePath == 'pubspec.yaml') { @@ -118,7 +118,7 @@ class FileReaderMock implements FileReader { } @override - String readAsString(String filePath, {Encoding encoding: utf8}) { + String readAsString(String filePath, {Encoding encoding = utf8}) { for (var file in _files) { if (file['path'] == filePath) return file['content']; } diff --git a/deprecated/flutter_data_view/lib/src/tag_list/screen.dart b/deprecated/flutter_data_view/lib/src/tag_list/screen.dart index 5f8f09f..9a9a51f 100644 --- a/deprecated/flutter_data_view/lib/src/tag_list/screen.dart +++ b/deprecated/flutter_data_view/lib/src/tag_list/screen.dart @@ -51,10 +51,8 @@ class _TaggedDataViewState extends State> { final allTags = [...folders, ...other].toSet().toList(); allTags.sort(); final emptyBuilder = () { - if (widget?.emptyBuilder != null) { - return widget.emptyBuilder(context); - } - return Scaffold( + return widget.emptyBuilder(context); + return Scaffold( appBar: AppBar( centerTitle: false, title: Text('Details'), @@ -66,10 +64,8 @@ class _TaggedDataViewState extends State> { }; final detailBuilder = (int index) { final T item = widget.dataSource.items[index]; - if (widget?.detailBuilder != null) { - return widget.detailBuilder(context, item, index); - } - return Scaffold( + return widget.detailBuilder(context, item, index); + return Scaffold( appBar: AppBar( centerTitle: false, title: Text('Details'), diff --git a/deprecated/flutter_data_view/lib/src/tag_list/source.dart b/deprecated/flutter_data_view/lib/src/tag_list/source.dart index 4281b1b..c4898eb 100644 --- a/deprecated/flutter_data_view/lib/src/tag_list/source.dart +++ b/deprecated/flutter_data_view/lib/src/tag_list/source.dart @@ -30,7 +30,6 @@ abstract class TaggedDataTableSource extends DataSource { } return Icons.info; }; - if (iconData() == null) return null; return Icon(iconData()); } @@ -64,16 +63,12 @@ abstract class TaggedDataTableSource extends DataSource { final _results = {}; for (var i = 0; i < rowCount; i++) { final tags = getTagsForRow(i); - if (_selected == null) { - _results[i] = getRow(i); - } else { - for (final tag in tags) { - if (tag.contains(_selected)) { - _results[i] = getRow(i); - } + for (final tag in tags) { + if (tag.contains(_selected)) { + _results[i] = getRow(i); } } - } + } final search = this.search.toLowerCase(); if (search.isEmpty) return _results; _results.clear(); diff --git a/deprecated/flutter_dynamic_widget/lib/src/accept.dart b/deprecated/flutter_dynamic_widget/lib/src/accept.dart index 9e1d70e..c8510c5 100644 --- a/deprecated/flutter_dynamic_widget/lib/src/accept.dart +++ b/deprecated/flutter_dynamic_widget/lib/src/accept.dart @@ -74,37 +74,33 @@ class __WidgetAcceptState extends State<_WidgetAccept> { @override Widget build(BuildContext context) { - if (widget.child != null) { - return widget.child; - } - if (!widget.scope.isDragging) { + return widget.child; + if (!widget.scope.isDragging) { return SizedBox.fromSize( size: widget.sizeOnlyDragging ? null : widget.size, child: Container(), ); } return SizedBox( - height: widget?.size?.height, - width: widget?.size?.width, + height: widget.size.height, + width: widget.size.width, child: DragTarget>( - onAccept: (val) { + onAcceptWithDetails: (val) { if (mounted) { setState(() { _accepting = false; }); } - if (val != null) { - final _data = val; - _data['id'] = StringGen.id; - if (_data['name'] == 'Text') { - _data['params']['style']['id'] = StringGen.id; - } - if (_data['name'] == 'Icon') { - _data['params']['0']['id'] = StringGen.id; - } - widget.onAccept(context, _data); + final _data = val; + _data['id'] = StringGen.id; + if (_data['name'] == 'Text') { + _data['params']['style']['id'] = StringGen.id; } - }, + if (_data['name'] == 'Icon') { + _data['params']['0']['id'] = StringGen.id; + } + widget.onAccept(context, _data); + }, onLeave: (val) { if (mounted) { setState(() { @@ -112,7 +108,7 @@ class __WidgetAcceptState extends State<_WidgetAccept> { }); } }, - onWillAccept: (val) { + onWillAcceptWithDetails: (val) { if (mounted) { setState(() { _accepting = true; @@ -123,11 +119,11 @@ class __WidgetAcceptState extends State<_WidgetAccept> { builder: (context, accepted, rejected) { return Center( child: Container( - width: widget?.size?.width, - height: widget?.size?.height, + width: widget.size.width, + height: widget.size.height, child: Placeholder( color: - !_accepting ? Colors.grey : Theme.of(context).accentColor, + !_accepting ? Colors.grey : Theme.of(context).colorScheme.secondary, ), ), ); @@ -143,13 +139,9 @@ Map modifyAccept(Map val, _data['id'] = StringGen.id; switch (_data['name']) { case 'Container': - if (height != null) { - _data['params']['height'] = height; - } - if (width != null) { - _data['params']['width'] = width; - } - break; + _data['params']['height'] = height; + _data['params']['width'] = width; + break; default: } return _data; diff --git a/deprecated/flutter_dynamic_widget/lib/src/base.dart b/deprecated/flutter_dynamic_widget/lib/src/base.dart index 0322553..b3b2ae2 100644 --- a/deprecated/flutter_dynamic_widget/lib/src/base.dart +++ b/deprecated/flutter_dynamic_widget/lib/src/base.dart @@ -25,104 +25,95 @@ class DynamicWidget extends StatelessWidget implements WidgetLibrary { } WidgetConfig get base { - if (data != null) { - if (library[data['name']] != null) { - final _base = library[data['name']]; - if (_base != null) { - return _base; - } + if (library[data['name']] != null) { + final _base = library[data['name']]; + if (_base != null) { + return _base; } } - if (unknownWidgetBuilder != null) { return unknownWidgetBuilder(data); - } - return null; + return null; } static void onAction(BuildContext context, String val) { final data = val; - if (data == null) return null; - if (data is String) { - if (data.isEmpty) return null; - final _data = data.replaceAll('#', ''); - if (_data.startsWith('message')) { - final _message = _data - .replaceAll('message(', '') - .replaceAll('(', '') - .replaceAll(')', ''); - Scaffold.of(context).showSnackBar(SnackBar( - content: Text(_message), - )); - return; - } - if (_data.startsWith('navigate')) { - final _route = _data - .replaceAll('navigate(', '') - .replaceAll('(', '') - .replaceAll(')', ''); - Navigator.of(context).pushNamed(_route); - return; - } - if (_data.startsWith('pop')) { - final _route = _data - .replaceAll('pop(', '') - .replaceAll('(', '') - .replaceAll(')', ''); - if (_route.isNotEmpty) { - Navigator.popUntil(context, ModalRoute.withName(_route)); - } else { - Navigator.of(context).pop(); - } - return; - } - if (_data.startsWith('maybePop')) { - Navigator.of(context).maybePop(); - return; - } - if (_data.startsWith('launch')) { - final _url = _data - .replaceAll("launch(", '') - .replaceAll('(', '') - .replaceAll(')', '') - .replaceAll("\'", ''); - launch('$_url'); - return; - } - if (_data.startsWith('alert')) { - final _message = _data - .replaceAll('alert(', '') - .replaceAll('(', '') - .replaceAll(')', ''); - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text('Info'), - content: Text(_message), - actions: [ - FlatButton( - child: Text('Ok'), - onPressed: () => Navigator.maybePop(context), - ), - ], - ), - ); - return; - } + if (data.isEmpty) return null; + final _data = data.replaceAll('#', ''); + if (_data.startsWith('message')) { + final _message = _data + .replaceAll('message(', '') + .replaceAll('(', '') + .replaceAll(')', ''); + Scaffold.of(context).showSnackBar(SnackBar( + content: Text(_message), + )); + return; } - return null; + if (_data.startsWith('navigate')) { + final _route = _data + .replaceAll('navigate(', '') + .replaceAll('(', '') + .replaceAll(')', ''); + Navigator.of(context).pushNamed(_route); + return; + } + if (_data.startsWith('pop')) { + final _route = _data + .replaceAll('pop(', '') + .replaceAll('(', '') + .replaceAll(')', ''); + if (_route.isNotEmpty) { + Navigator.popUntil(context, ModalRoute.withName(_route)); + } else { + Navigator.of(context).pop(); + } + return; + } + if (_data.startsWith('maybePop')) { + Navigator.of(context).maybePop(); + return; + } + if (_data.startsWith('launch')) { + final _url = _data + .replaceAll("launch(", '') + .replaceAll('(', '') + .replaceAll(')', '') + .replaceAll("\'", ''); + launch('$_url'); + return; + } + if (_data.startsWith('alert')) { + final _message = _data + .replaceAll('alert(', '') + .replaceAll('(', '') + .replaceAll(')', ''); + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Info'), + content: Text(_message), + actions: [ + FlatButton( + child: Text('Ok'), + onPressed: () => Navigator.maybePop(context), + ), + ], + ), + ); + return; + } + return null; } Widget render(BuildContext context, [bool nullOk = false]) { - if (base != null) { - if (base is WidgetBase) { - return Builder( - builder: (context) { - return (base as WidgetBase)?.build(context); - }, - ); - } + if (base is WidgetBase) { + return Builder( + builder: (context) { + return (base as WidgetBase).build(context); + }, + ); } - if (nullOk) { + if (nullOk) { return null; } return Container(); diff --git a/deprecated/flutter_dynamic_widget/lib/src/material/library.dart b/deprecated/flutter_dynamic_widget/lib/src/material/library.dart index 0a5bbac..1f3ef07 100644 --- a/deprecated/flutter_dynamic_widget/lib/src/material/library.dart +++ b/deprecated/flutter_dynamic_widget/lib/src/material/library.dart @@ -1,6 +1,4 @@ import '../../flutter_dynamic_widget.dart'; -import '../base.dart'; -import './index.dart'; class MaterialBase extends WidgetLibrary { MaterialBase(this.data, this.widgetContext); @@ -10,7 +8,7 @@ class MaterialBase extends WidgetLibrary { GenerateWidget get widgetRender => (context, data) { if (data is Map) { final _base = MaterialBase(data, context); - final _config = _base?.base; + final _config = _base.base; if (_config is WidgetBase) { return _config; } @@ -40,14 +38,13 @@ class MaterialBase extends WidgetLibrary { @override WidgetConfig get base { - if (data == null) return null; final name = data['name'].toString(); final _materialBase = library[name]; if (_materialBase != null) return _materialBase; return DynamicWidget( data: data, widgetContext: widgetContext, - )?.base; + ).base; } static ActionCallback onAction = (context, val) { diff --git a/deprecated/flutter_dynamic_widget/lib/src/utils.dart b/deprecated/flutter_dynamic_widget/lib/src/utils.dart index f52e60e..f4c58b8 100644 --- a/deprecated/flutter_dynamic_widget/lib/src/utils.dart +++ b/deprecated/flutter_dynamic_widget/lib/src/utils.dart @@ -3,7 +3,6 @@ import 'package:url_launcher/url_launcher.dart'; import 'string_gen.dart'; T getEnum(String val, {T fallback, List values}) { - if (val == null) return fallback; final _value = val.replaceAll('#', ''); return values.firstWhere( (element) => element.toString() == _value, @@ -21,7 +20,6 @@ Key getKey(dynamic value, [Key fallback]) { } Paint getPaint(Map data, [Paint fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; // TODO: get values here @@ -29,7 +27,6 @@ Paint getPaint(Map data, [Paint fallback]) { } Decoration getDecoration(Map data, [Decoration fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; // TODO: get values here @@ -37,7 +34,6 @@ Decoration getDecoration(Map data, [Decoration fallback]) { } Duration getDuration(Map data, [Duration fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; if (!params.toString().contains('zero')) { @@ -62,7 +58,6 @@ Duration getDuration(Map data, [Duration fallback]) { BorderRadiusGeometry getBorderRadiusGeometry(Map data, [BorderRadiusGeometry fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; // TODO: get values here @@ -70,7 +65,6 @@ BorderRadiusGeometry getBorderRadiusGeometry(Map data, } Matrix4 getMatrix4(Map data, [Matrix4 fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; // TODO: get values here @@ -79,7 +73,6 @@ Matrix4 getMatrix4(Map data, [Matrix4 fallback]) { BorderStyle getBorderStyle(Map data, [BorderStyle fallback = BorderStyle.none]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; // TODO: get values here @@ -87,7 +80,6 @@ BorderStyle getBorderStyle(Map data, } FocusNode getFocusNode(Map data, [FocusNode fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; final debugLabel = getString(params['debugLabel']); @@ -104,7 +96,6 @@ FocusNode getFocusNode(Map data, [FocusNode fallback]) { BorderSide getBorderSide(Map data, [BorderSide fallback = BorderSide.none]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; return null; @@ -133,7 +124,6 @@ List getAlignmentValues() { } ShapeBorder getShapeBorder(Map data, [ShapeBorder fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; final top = getBorderSide(params['top']); @@ -167,7 +157,6 @@ ShapeBorder getShapeBorder(Map data, [ShapeBorder fallback]) { } Offset getOffset(Map data, [Offset fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; final dx = getDouble(params['dx']); @@ -176,7 +165,6 @@ Offset getOffset(Map data, [Offset fallback]) { } BoxShadow getBoxShadow(Map data, [BoxShadow fallback]) { - if (data == null) return fallback; if (data['params'] == null) return fallback; final params = data['params']; final color = getColor(params['color']); @@ -226,16 +214,14 @@ Map setIconData(IconData value) { 'id': StringGen.id, 'params': { '0': value.codePoint, - if (value?.fontFamily != null) 'fontFamily': value?.fontFamily, - if (value?.fontPackage != null) 'fontPackage': value?.fontPackage, - if (value?.matchTextDirection != null) - 'matchTextDirection': value?.matchTextDirection, + if (value.fontFamily != null) 'fontFamily': value.fontFamily, + if (value.fontPackage != null) 'fontPackage': value.fontPackage, + 'matchTextDirection': value.matchTextDirection, }, }; } IconData getIconData(Map data, [IconData fallback]) { - if (data == null) return fallback; final name = data['name']; if (name == 'IconData') { final params = data['params']; @@ -258,10 +244,10 @@ IconData getIconData(Map data, [IconData fallback]) { getBool(params['matchTextDirection'], matchTextDirection); } return IconData( - codePoint ?? fallback?.codePoint, - fontFamily: fontFamily ?? fallback?.fontFamily, - fontPackage: fontPackage ?? fallback?.fontPackage, - matchTextDirection: matchTextDirection ?? fallback?.matchTextDirection, + codePoint ?? fallback.codePoint, + fontFamily: fontFamily ?? fallback.fontFamily, + fontPackage: fontPackage ?? fallback.fontPackage, + matchTextDirection: matchTextDirection ?? fallback.matchTextDirection, ); } return fallback; @@ -455,10 +441,10 @@ Map setEdgeInsets(EdgeInsets val) { 'id': StringGen.id, 'name': 'EdgeInsets.only', 'params': { - 'top': val?.top ?? 0, - 'bottom': val?.bottom ?? 0, - 'left': val?.left ?? 0, - 'right': val?.right ?? 0, + 'top': val.top ?? 0, + 'bottom': val.bottom ?? 0, + 'left': val.left ?? 0, + 'right': val.right ?? 0, }, }; } @@ -471,10 +457,10 @@ extension EdgeInsetUtils on EdgeInsets { double bottom, ]) { return EdgeInsets.only( - top: top ?? this?.top ?? 0, - left: left ?? this?.left ?? 0, - right: right ?? this?.right ?? 0, - bottom: bottom ?? this?.bottom ?? 0, + top: top ?? this.top ?? 0, + left: left ?? this.left ?? 0, + right: right ?? this.right ?? 0, + bottom: bottom ?? this.bottom ?? 0, ); } diff --git a/deprecated/flutter_dynamic_widget/lib/src/widget_config.dart b/deprecated/flutter_dynamic_widget/lib/src/widget_config.dart index 5ec4057..89045b8 100644 --- a/deprecated/flutter_dynamic_widget/lib/src/widget_config.dart +++ b/deprecated/flutter_dynamic_widget/lib/src/widget_config.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:meta/meta.dart'; import 'base_class.dart'; import 'widget_index.dart'; diff --git a/deprecated/flutter_dynamic_widget/lib/src/widget_index.dart b/deprecated/flutter_dynamic_widget/lib/src/widget_index.dart index be36d38..a27bd77 100644 --- a/deprecated/flutter_dynamic_widget/lib/src/widget_index.dart +++ b/deprecated/flutter_dynamic_widget/lib/src/widget_index.dart @@ -941,13 +941,11 @@ class WidgetIndex { Map toMap() { return { 'version': version, - 'widgets': widgets?.map((x) => x?.toMap())?.toList(), + 'widgets': widgets.map((x) => x.toMap()).toList(), }; } static WidgetIndex fromMap(Map map) { - if (map == null) return null; - return WidgetIndex( version: map['version'], widgets: List.from( @@ -980,8 +978,6 @@ class FlutterWidget { } static FlutterWidget fromMap(Map map) { - if (map == null) return null; - return FlutterWidget( name: map['name'], description: map['description'], diff --git a/deprecated/flutter_midi/lib/src/platform_interface.dart b/deprecated/flutter_midi/lib/src/platform_interface.dart index 3fd6ab5..000d582 100644 --- a/deprecated/flutter_midi/lib/src/platform_interface.dart +++ b/deprecated/flutter_midi/lib/src/platform_interface.dart @@ -1,5 +1,4 @@ import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'method_channel.dart'; diff --git a/deprecated/flutter_multi_window/lib/src/new_window/web.dart b/deprecated/flutter_multi_window/lib/src/new_window/web.dart index 4136eb6..258b458 100644 --- a/deprecated/flutter_multi_window/lib/src/new_window/web.dart +++ b/deprecated/flutter_multi_window/lib/src/new_window/web.dart @@ -10,17 +10,9 @@ void newWindow( }) { final screen = html.window.screen; double top = 0; - if (dy != null) { - top = dy; - } else if (screen.height != null) { - top = (screen.height - height) / 2; - } + top = dy; double left = 0; - if (dx != null) { - left = dx; - } else if (screen.width != null) { - left = (screen.width - width) / 2; - } + left = dx; final sb = StringBuffer(); sb.write("height="); sb.write(height); diff --git a/deprecated/flutter_multi_window/lib/src/window.dart b/deprecated/flutter_multi_window/lib/src/window.dart index d52e312..15ef996 100644 --- a/deprecated/flutter_multi_window/lib/src/window.dart +++ b/deprecated/flutter_multi_window/lib/src/window.dart @@ -64,8 +64,6 @@ class NewWindow { } static NewWindow fromMap(Map map) { - if (map == null) return null; - return NewWindow( url: map['url'], width: map['width'], @@ -114,8 +112,8 @@ void createWindow(NewWindow window) { window.url, window.width, window.height, - dx: window?.offsetX, - dy: window?.offsetY, - name: window?.name, + dx: window.offsetX, + dy: window.offsetY, + name: window.name, ); } diff --git a/deprecated/flutter_multi_window/main.dart b/deprecated/flutter_multi_window/main.dart index 3446314..d8dbed9 100644 --- a/deprecated/flutter_multi_window/main.dart +++ b/deprecated/flutter_multi_window/main.dart @@ -84,10 +84,10 @@ class _MyAppState extends State { final height = size.height; final width = size.width; final sb = StringBuffer(); - final top = offset?.dy ?? + final top = offset.dy ?? (screen.height != null ? (screen.height - height) / 2 : 0); final left = - offset?.dx ?? (screen.width != null ? (screen.width - width) / 2 : 0); + offset.dx ?? (screen.width != null ? (screen.width - width) / 2 : 0); sb.write("height="); sb.write(height); sb.write(",width="); diff --git a/deprecated/flutter_wasm_interop/example/lib/main.dart b/deprecated/flutter_wasm_interop/example/lib/main.dart index bc42dd6..1f85edb 100644 --- a/deprecated/flutter_wasm_interop/example/lib/main.dart +++ b/deprecated/flutter_wasm_interop/example/lib/main.dart @@ -62,7 +62,7 @@ class _MyHomePageState extends State { ), Text( '$_counter', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), ], ), diff --git a/deprecated/flutter_wasm_interop/lib/src/web.dart b/deprecated/flutter_wasm_interop/lib/src/web.dart index 42db508..7a39bf5 100644 --- a/deprecated/flutter_wasm_interop/lib/src/web.dart +++ b/deprecated/flutter_wasm_interop/lib/src/web.dart @@ -32,7 +32,6 @@ class WasmLoader extends WasmImpl { @override Future init() async { - assert(_path != null); final _data = await rootBundle.load(_path); _wasm = await Instance.fromBufferAsync(_data.buffer); return isReady; diff --git a/deprecated/get_version/example/lib/main.dart b/deprecated/get_version/example/lib/main.dart index 36b706c..46affb8 100644 --- a/deprecated/get_version/example/lib/main.dart +++ b/deprecated/get_version/example/lib/main.dart @@ -26,9 +26,7 @@ void _setTargetPlatformForDesktop() { } else if (Platform.isLinux || Platform.isWindows) { targetPlatform = TargetPlatform.android; } - if (targetPlatform != null) { - debugDefaultTargetPlatformOverride = targetPlatform; - } + debugDefaultTargetPlatformOverride = targetPlatform; } class MyApp extends StatefulWidget { diff --git a/deprecated/golden_layout/example/lib/main.dart b/deprecated/golden_layout/example/lib/main.dart index ab5aef1..6db9cf1 100644 --- a/deprecated/golden_layout/example/lib/main.dart +++ b/deprecated/golden_layout/example/lib/main.dart @@ -12,9 +12,7 @@ class MyApp extends StatelessWidget { debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: ThemeData( - primarySwatch: Colors.blue, - accentColor: Colors.red, - visualDensity: VisualDensity.adaptivePlatformDensity, + visualDensity: VisualDensity.adaptivePlatformDensity, colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.blue).copyWith(secondary: Colors.red), ), home: MyHomePage(title: 'Flutter Golden Layout'), ); @@ -88,7 +86,7 @@ class _MyHomePageState extends State { ), body: GoldenLayoutTheme( data: GoldenLayoutThemeData( - tabSelectedBackgroundColor: Theme.of(context).accentColor, + tabSelectedBackgroundColor: Theme.of(context).colorScheme.secondary, ), child: GoldenLayout( controller: _controller, @@ -103,7 +101,7 @@ class _MyHomePageState extends State { title: (context, selected, index) => Text( 'Window $count', style: TextStyle( - color: selected ? Theme.of(context).accentColor : Colors.white, + color: selected ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), child: Container(color: Colors.red[100 * count])); diff --git a/deprecated/golden_layout/lib/golden_layout.dart b/deprecated/golden_layout/lib/golden_layout.dart index 7e41c08..925e37f 100644 --- a/deprecated/golden_layout/lib/golden_layout.dart +++ b/deprecated/golden_layout/lib/golden_layout.dart @@ -34,55 +34,51 @@ class _GoldenLayoutState extends State { @override void initState() { - _controller = widget?.controller ?? WindowController(); - if (widget?.collection != null) { - _controller.base = widget.collection; - } - super.initState(); + _controller = widget.controller ?? WindowController(); + _controller.base = widget.collection; + super.initState(); } @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, dimens) { - if (_controller.fullScreen != null) { - return RenderWindowGroup( - onAddTab: widget.onAddTab, - onCancel: (val) { - _controller.addToBase(val); - }, - isDragging: _isDragging, - onDraggingChanged: (val) { - if (mounted) { - setState(() { - _isDragging = val; - }); - } - }, - popUpSize: widget.popupSize, - minimize: true, - group: _controller.fullScreen, - onFullScreen: () { - if (mounted) { - setState(() { - _controller.exitFullScreen(); - }); - } - }, - onClose: !_controller.fullScreen.canClose - ? null - : () { - if (mounted) { - setState(() { - _controller.exitFullScreen(true); - }); - } - }, - update: () { - if (mounted) setState(() {}); - }, - ); - } - return _renderItem( + return RenderWindowGroup( + onAddTab: widget.onAddTab, + onCancel: (val) { + _controller.addToBase(val); + }, + isDragging: _isDragging, + onDraggingChanged: (val) { + if (mounted) { + setState(() { + _isDragging = val; + }); + } + }, + popUpSize: widget.popupSize, + minimize: true, + group: _controller.fullScreen, + onFullScreen: () { + if (mounted) { + setState(() { + _controller.exitFullScreen(); + }); + } + }, + onClose: !_controller.fullScreen.canClose + ? null + : () { + if (mounted) { + setState(() { + _controller.exitFullScreen(true); + }); + } + }, + update: () { + if (mounted) setState(() {}); + }, + ); + return _renderItem( _controller.base, index: 0, size: Size(dimens.maxWidth, dimens.maxHeight), diff --git a/deprecated/golden_layout/lib/src/border_accept.dart b/deprecated/golden_layout/lib/src/border_accept.dart index 3b2d7ca..e993d8b 100644 --- a/deprecated/golden_layout/lib/src/border_accept.dart +++ b/deprecated/golden_layout/lib/src/border_accept.dart @@ -27,7 +27,7 @@ class _WindowAcceptRegionState extends State { @override Widget build(BuildContext context) { return SizedBox.fromSize( - size: widget?.size, + size: widget.size, child: LayoutBuilder( builder: (context, dimens) => Stack( fit: StackFit.expand, @@ -42,22 +42,22 @@ class _WindowAcceptRegionState extends State { ), ), Positioned.fill( - left: widget?.left ?? 0, - right: widget?.right ?? 0, - top: widget?.top ?? 0, - bottom: widget?.bottom ?? 0, + left: widget.left ?? 0, + right: widget.right ?? 0, + top: widget.top ?? 0, + bottom: widget.bottom ?? 0, child: Container( child: DragTarget( builder: (context, accepted, rejected) => Container(), - onAccept: (val) { + onAcceptWithDetails: (val) { if (mounted) { setState(() { accepting = false; }); } - if (widget.onAccept != null) widget.onAccept(val); + widget.onAccept(val); }, - onWillAccept: (val) { + onWillAcceptWithDetails: (val) { if (mounted) { setState(() { accepting = true; diff --git a/deprecated/golden_layout/lib/src/controller.dart b/deprecated/golden_layout/lib/src/controller.dart index 3ffa878..f7321c3 100644 --- a/deprecated/golden_layout/lib/src/controller.dart +++ b/deprecated/golden_layout/lib/src/controller.dart @@ -24,12 +24,8 @@ class WindowController extends ChangeNotifier { WindowCollection base = WindowColumn([]); void addToBase(WindowTab tab) { - if (base == null) { - base = WindowColumn([WindowGroup(tab)]); - } else { - _addTab(base, tab); - } - notifyListeners(); + _addTab(base, tab); + notifyListeners(); } bool _addTab(WindowCollection item, WindowTab tab) { diff --git a/deprecated/golden_layout/lib/src/window.dart b/deprecated/golden_layout/lib/src/window.dart index 60e2116..307d431 100644 --- a/deprecated/golden_layout/lib/src/window.dart +++ b/deprecated/golden_layout/lib/src/window.dart @@ -36,7 +36,7 @@ class WindowColumn extends WindowCollection { class WindowGroup extends WindowCollection { WindowGroup([WindowTab tab, bool closeable = true]) { - if (tab != null) _tabs.add(tab); + _tabs.add(tab); canClose = closeable; } bool canClose = true; @@ -56,14 +56,9 @@ class WindowGroup extends WindowCollection { } void addTab(WindowTab tab, [int index]) { - if (index != null) { - _tabs.insert(index, tab); - _activeTab = index; - } else { - _tabs.add(tab); - _activeTab = _tabs.length - 1; - } - notifyListeners(); + _tabs.insert(index, tab); + _activeTab = index; + notifyListeners(); } void removeTab(WindowTab tab) { diff --git a/deprecated/golden_layout/lib/src/window_group.dart b/deprecated/golden_layout/lib/src/window_group.dart index 6c5a37e..3238822 100644 --- a/deprecated/golden_layout/lib/src/window_group.dart +++ b/deprecated/golden_layout/lib/src/window_group.dart @@ -54,11 +54,11 @@ class _RenderWindowGroupState extends State { @override Widget build(BuildContext context) { final _theme = - GoldenLayoutTheme.of(context)?.theme ?? GoldenLayoutThemeData(); + GoldenLayoutTheme.of(context).theme ?? GoldenLayoutThemeData(); return Column( children: [ Container( - color: _theme?.backgroundColor, + color: _theme.backgroundColor, height: 32, child: Row( children: [ @@ -72,13 +72,12 @@ class _RenderWindowGroupState extends State { for (var i = 0; i < widget.group.tabs.length; i++) Draggable( data: widget.group.tabs[i], - dragAnchor: DragAnchor.child, onDragStarted: () { _draggingTab = widget.group.tabs[i]; widget.group.removeTab(_draggingTab); widget.update(); if (widget.group.tabs.isEmpty) { - widget.onClose?.call(); + widget.onClose.call(); } widget.onDraggingChanged(true); }, @@ -128,7 +127,7 @@ class _RenderWindowGroupState extends State { }); } }, - onWillAccept: (val) { + onWillAcceptWithDetails: (val) { if (mounted) { setState(() { accepting = i; @@ -136,7 +135,7 @@ class _RenderWindowGroupState extends State { } return true; }, - onAccept: (val) { + onAcceptWithDetails: (val) { widget.onModify( context, val, WindowPos.tab, accepting); if (mounted) { @@ -155,9 +154,9 @@ class _RenderWindowGroupState extends State { child: Container( decoration: BoxDecoration( color: selected - ? _theme?.tabSelectedBackgroundColor ?? + ? _theme.tabSelectedBackgroundColor ?? Colors.grey.shade600 - : _theme?.backgroundColor, + : _theme.backgroundColor, borderRadius: selected ? BorderRadius.only( topLeft: Radius.circular(5), @@ -197,17 +196,17 @@ class _RenderWindowGroupState extends State { child: Icon( Icons.close, size: 18, - color: _theme?.tabIconColor ?? + color: _theme.tabIconColor ?? Colors.white, ), onTap: () { widget.group.tabs[i].onClose - ?.call(); + .call(); widget.group.removeTab( widget.group.tabs[i]); widget.update(); if (widget.group.tabs.isEmpty) { - widget.onClose?.call(); + widget.onClose.call(); } }, ), @@ -225,17 +224,16 @@ class _RenderWindowGroupState extends State { ), ); }, - ), + ), dragAnchorStrategy: childDragAnchorStrategy, ), - if (widget.onAddTab != null) - IconButton( - iconSize: 20, - icon: Icon( - Icons.add, - color: Colors.white, - ), - onPressed: () => - widget.group.addTab(widget.onAddTab())), + IconButton( + iconSize: 20, + icon: Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () => + widget.group.addTab(widget.onAddTab())), if (widget.isDragging) WindowAcceptRegion( size: Size(100, 32), @@ -249,18 +247,17 @@ class _RenderWindowGroupState extends State { ), ), IconButton( - color: _theme?.tabIconColor ?? Colors.white, + color: _theme.tabIconColor ?? Colors.white, iconSize: 18, icon: Icon(widget.minimize ? Icons.minimize : Icons.fullscreen), onPressed: widget.onFullScreen, ), - if (widget.onClose != null) - IconButton( - color: _theme?.tabIconColor ?? Colors.white, - iconSize: 18, - icon: Icon(Icons.close), - onPressed: widget.onClose, - ), + IconButton( + color: _theme.tabIconColor ?? Colors.white, + iconSize: 18, + icon: Icon(Icons.close), + onPressed: widget.onClose, + ), ], ), ), diff --git a/deprecated/image_resizer/example/lib/main.dart b/deprecated/image_resizer/example/lib/main.dart index 8c113bd..482b6da 100644 --- a/deprecated/image_resizer/example/lib/main.dart +++ b/deprecated/image_resizer/example/lib/main.dart @@ -17,8 +17,7 @@ class MyApp extends StatelessWidget { debugShowCheckedModeBanner: false, title: 'Flutter Icon Resizer', theme: ThemeData.light().copyWith( - primaryColor: Colors.blue, - accentColor: Colors.red, + primaryColor: Colors.blue, colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.red), ), darkTheme: ThemeData.dark(), home: HomeScreen(), @@ -179,10 +178,8 @@ class _HomeScreenState extends State { if (kIsWeb) { Uri dataUrl; try { - if (binaryData != null) { - dataUrl = Uri.dataFromBytes(binaryData); - } - } catch (e) { + dataUrl = Uri.dataFromBytes(binaryData); + } catch (e) { if (!silentErrors) { throw Exception("Error Creating File Data: $e"); } @@ -315,7 +312,7 @@ class _HomeScreenState extends State { SwitchListTile( title: Text( 'Export $name Icons', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), value: toggle, onChanged: onChanged, @@ -338,27 +335,27 @@ class _HomeScreenState extends State { DataTable( columns: [ DataColumn(label: Text('Size')), - if (icons is List) ...[ - DataColumn(label: Text('Prefix')), - DataColumn(label: Text('Ext')), - DataColumn(label: Text('Scale')), - DataColumn(label: Text('Point5')), - ], - if (icons is List) ...[ - DataColumn(label: Text('Prefix')), - DataColumn(label: Text('Ext')), - DataColumn(label: Text('Scale')), - ], - if (icons is List) ...[ - DataColumn(label: Text('Prefix')), - DataColumn(label: Text('Ext')), - ], - if (icons is List) ...[ - DataColumn(label: Text('Name')), - DataColumn(label: Text('Folder')), - DataColumn(label: Text('Suffix')), - DataColumn(label: Text('Ext')), - ], + ...[ + DataColumn(label: Text('Prefix')), + DataColumn(label: Text('Ext')), + DataColumn(label: Text('Scale')), + DataColumn(label: Text('Point5')), + ], + ...[ + DataColumn(label: Text('Prefix')), + DataColumn(label: Text('Ext')), + DataColumn(label: Text('Scale')), + ], + ...[ + DataColumn(label: Text('Prefix')), + DataColumn(label: Text('Ext')), + ], + ...[ + DataColumn(label: Text('Name')), + DataColumn(label: Text('Folder')), + DataColumn(label: Text('Suffix')), + DataColumn(label: Text('Ext')), + ], DataColumn(label: Text('Delete')), ], rows: [ @@ -396,258 +393,258 @@ class _HomeScreenState extends State { ), ), ), - if (icons is List) ...[ - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Prefix', - ), - initialValue: icons[i].prefix, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(prefix: val); - }); - } catch (e) {} - }, + ...[ + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Prefix', ), - ), - ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Ext', - ), - initialValue: icons[i].ext, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(ext: val); - }); - } catch (e) {} - }, - ), - ), - ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Scale', - ), - initialValue: icons[i].scale.toString(), - onChanged: (val) { - try { - if (mounted) - setState(() { - final _value = int.tryParse(val); - icons[i] = - icons[i].copyWith(scale: _value); - }); - } catch (e) {} - }, - ), - ), - ), - DataCell( - Switch( - value: icons[i].point5, + initialValue: icons[i].prefix, onChanged: (val) { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(point5: val); - }); + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(prefix: val); + }); + } catch (e) {} }, ), ), - ], - if (icons is List) ...[ - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Prefix', - ), - initialValue: icons[i].prefix, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(prefix: val); - }); - } catch (e) {} - }, + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Ext', ), + initialValue: icons[i].ext, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(ext: val); + }); + } catch (e) {} + }, ), ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Ext', - ), - initialValue: icons[i].ext, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(ext: val); - }); - } catch (e) {} - }, + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Scale', ), + initialValue: icons[i].scale.toString(), + onChanged: (val) { + try { + if (mounted) + setState(() { + final _value = int.tryParse(val); + icons[i] = + icons[i].copyWith(scale: _value); + }); + } catch (e) {} + }, ), ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Scale', - ), - initialValue: icons[i].scale.toString(), - onChanged: (val) { - try { - if (mounted) - setState(() { - final _value = int.tryParse(val); - icons[i] = - icons[i].copyWith(scale: _value); - }); - } catch (e) {} - }, + ), + DataCell( + Switch( + value: icons[i].point5, + onChanged: (val) { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(point5: val); + }); + }, + ), + ), + ], + ...[ + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Prefix', ), + initialValue: icons[i].prefix, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(prefix: val); + }); + } catch (e) {} + }, ), ), - ], - if (icons is List) ...[ - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Prefix', - ), - initialValue: icons[i].prefix, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(prefix: val); - }); - } catch (e) {} - }, + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Ext', ), + initialValue: icons[i].ext, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(ext: val); + }); + } catch (e) {} + }, ), ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Ext', - ), - initialValue: icons[i].ext, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(ext: val); - }); - } catch (e) {} - }, + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Scale', ), + initialValue: icons[i].scale.toString(), + onChanged: (val) { + try { + if (mounted) + setState(() { + final _value = int.tryParse(val); + icons[i] = + icons[i].copyWith(scale: _value); + }); + } catch (e) {} + }, ), ), - ], - if (icons is List) ...[ - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Name', - ), - initialValue: icons[i].name, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(name: val); - }); - } catch (e) {} - }, + ), + ], + ...[ + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Prefix', ), + initialValue: icons[i].prefix, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(prefix: val); + }); + } catch (e) {} + }, ), ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Folder', - ), - initialValue: icons[i].folder, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(folder: val); - }); - } catch (e) {} - }, + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Ext', ), + initialValue: icons[i].ext, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(ext: val); + }); + } catch (e) {} + }, ), ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Suffix', - ), - initialValue: icons[i].folderSuffix, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = - icons[i].copyWith(folderSuffix: val); - }); - } catch (e) {} - }, + ), + ], + ...[ + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Name', ), + initialValue: icons[i].name, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(name: val); + }); + } catch (e) {} + }, ), ), - DataCell( - SizedBox( - width: 100, - child: TextFormField( - decoration: InputDecoration.collapsed( - hintText: 'Ext', - ), - initialValue: icons[i].ext, - onChanged: (val) { - try { - if (mounted) - setState(() { - icons[i] = icons[i].copyWith(ext: val); - }); - } catch (e) {} - }, + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Folder', ), + initialValue: icons[i].folder, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(folder: val); + }); + } catch (e) {} + }, ), ), - ], + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Suffix', + ), + initialValue: icons[i].folderSuffix, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = + icons[i].copyWith(folderSuffix: val); + }); + } catch (e) {} + }, + ), + ), + ), + DataCell( + SizedBox( + width: 100, + child: TextFormField( + decoration: InputDecoration.collapsed( + hintText: 'Ext', + ), + initialValue: icons[i].ext, + onChanged: (val) { + try { + if (mounted) + setState(() { + icons[i] = icons[i].copyWith(ext: val); + }); + } catch (e) {} + }, + ), + ), + ), + ], DataCell( IconButton( icon: Icon(Icons.delete), @@ -668,39 +665,31 @@ class _HomeScreenState extends State { onPressed: () { if (mounted) setState(() { - if (icons is List) { - icons.add( - IosIcon( - size: 1024, - scale: 1, - ), - ); - } - if (icons is List) { - icons.add( - WebIcon( - size: 192, - ), - ); - } - if (icons is List) { - icons.add( - MacOSIcon( - size: 512, - scale: 2, - name: '1024', - ), - ); - } - if (icons is List) { - icons.add( - AndroidIcon( - size: 192, - folderSuffix: "xxxhdpi", - ), - ); - } - }); + icons.add( + IosIcon( + size: 1024, + scale: 1, + ), + ); + icons.add( + WebIcon( + size: 192, + ), + ); + icons.add( + MacOSIcon( + size: 512, + scale: 2, + name: '1024', + ), + ); + icons.add( + AndroidIcon( + size: 192, + folderSuffix: "xxxhdpi", + ), + ); + }); }, ), ], @@ -711,9 +700,6 @@ class _HomeScreenState extends State { } Widget _buildFilePreview() { - if (_files == null) { - return Center(child: CircularProgressIndicator()); - } return ListView.separated( separatorBuilder: (context, index) => Container( height: 1.0, @@ -729,7 +715,7 @@ class _HomeScreenState extends State { children: [ Text( _key, - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), Padding( padding: const EdgeInsets.all(8.0), diff --git a/deprecated/image_resizer/lib/src/template.dart b/deprecated/image_resizer/lib/src/template.dart index 0edb7be..037cc99 100644 --- a/deprecated/image_resizer/lib/src/template.dart +++ b/deprecated/image_resizer/lib/src/template.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'package:meta/meta.dart'; diff --git a/deprecated/mobile_popup/example/lib/main.dart b/deprecated/mobile_popup/example/lib/main.dart index 90d1571..2925a15 100644 --- a/deprecated/mobile_popup/example/lib/main.dart +++ b/deprecated/mobile_popup/example/lib/main.dart @@ -21,9 +21,7 @@ void _setTargetPlatformForDesktop() { } else if (Platform.isLinux || Platform.isWindows) { targetPlatform = TargetPlatform.android; } - if (targetPlatform != null) { - debugDefaultTargetPlatformOverride = targetPlatform; - } + debugDefaultTargetPlatformOverride = targetPlatform; } class MyApp extends StatefulWidget { diff --git a/deprecated/mobile_popup/lib/mobile_popup.dart b/deprecated/mobile_popup/lib/mobile_popup.dart index 80a5e2b..89964ab 100644 --- a/deprecated/mobile_popup/lib/mobile_popup.dart +++ b/deprecated/mobile_popup/lib/mobile_popup.dart @@ -77,7 +77,7 @@ class _MobilePopUpState extends State { void init() { if (mounted) setState(() { - leadingColor = widget?.leadingColor; + leadingColor = widget.leadingColor; }); } @@ -88,10 +88,10 @@ class _MobilePopUpState extends State { _size.height < widget.breakpoint.height; final _full = _mobile || fullscreen; final _content = _PopUpContent( - title: widget?.title, + title: widget.title, showDoneButton: widget.showDoneButton, - child: widget?.child, - routes: widget?.routes, + child: widget.child, + routes: widget.routes, leadingColor: leadingColor, fullscreen: !widget.showFullScreen ? null : fullscreen, toggleFullscreen: (value) { @@ -155,14 +155,13 @@ class _PopUpContent extends StatelessWidget { ) : null, actions: [ - if (fullscreen != null) - IconButton( - icon: - Icon(fullscreen ? Icons.fullscreen_exit : Icons.fullscreen), - onPressed: () => toggleFullscreen(!fullscreen), - ) + IconButton( + icon: + Icon(fullscreen ? Icons.fullscreen_exit : Icons.fullscreen), + onPressed: () => toggleFullscreen(!fullscreen), + ) ], - title: title == null ? null : Text(title), + title: Text(title), ), body: child, ), diff --git a/deprecated/mobile_popup/lib/pop_up.dart b/deprecated/mobile_popup/lib/pop_up.dart index 20e3659..31a5f6e 100644 --- a/deprecated/mobile_popup/lib/pop_up.dart +++ b/deprecated/mobile_popup/lib/pop_up.dart @@ -23,7 +23,7 @@ Future showMobilePopup({ Animation secondaryAnimation) { final Widget pageChild = Builder(builder: builder); return Builder(builder: (BuildContext context) { - return theme != null ? Theme(data: theme, child: pageChild) : pageChild; + return Theme(data: theme, child: pageChild); }); }, barrierDismissible: barrierDismissible, diff --git a/deprecated/mobile_sidebar/example/lib/main.dart b/deprecated/mobile_sidebar/example/lib/main.dart index d70c16b..eca6b84 100644 --- a/deprecated/mobile_sidebar/example/lib/main.dart +++ b/deprecated/mobile_sidebar/example/lib/main.dart @@ -151,9 +151,6 @@ class FancyTitle extends StatelessWidget { @override Widget build(BuildContext context) { - if (logo == null) { - return logo; - } return Row( children: [ logo, diff --git a/deprecated/mobile_sidebar/lib/mobile_sidebar.dart b/deprecated/mobile_sidebar/lib/mobile_sidebar.dart index 3f4de62..18e06f1 100644 --- a/deprecated/mobile_sidebar/lib/mobile_sidebar.dart +++ b/deprecated/mobile_sidebar/lib/mobile_sidebar.dart @@ -1,9 +1,6 @@ -import 'dart:math'; import 'package:auto_size_text/auto_size_text.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; class TabChild { final String title; @@ -72,15 +69,13 @@ class MobileSidebar extends StatelessWidget { return Scaffold( key: _scaffoldKey, drawer: _showDrawer - ? drawerBuilder != null - ? drawerBuilder(context, _titles, onTabChanged) - : _buildDrawer(context, _titles) + ? drawerBuilder(context, _titles, onTabChanged) : null, appBar: PreferredSize( preferredSize: Size.fromHeight(kToolbarHeight), child: Material( color: theme.appBarTheme.color, - elevation: theme.appBarTheme?.elevation ?? 4.0, + elevation: theme.appBarTheme.elevation ?? 4.0, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -187,8 +182,8 @@ class MobileSidebar extends StatelessWidget { if (showSearchButton) ...[ _searchBuilder(context, _showDrawer), ], - if (ctaBuilder != null) ctaBuilder(context), - if (accountBuilder != null) accountBuilder(context), + ctaBuilder(context), + accountBuilder(context), ], ), ], @@ -216,7 +211,7 @@ class MobileSidebar extends StatelessWidget { child: Center( child: AutoSizeText( tab, - style: theme.textTheme.body2.copyWith( + style: theme.textTheme.bodyLarge.copyWith( color: Colors.black, ), ), @@ -227,7 +222,7 @@ class MobileSidebar extends StatelessWidget { height: kBarHeight, width: tabWidth * 2, color: tab == _titles[currentIndex] - ? theme.accentColor + ? theme.colorScheme.secondary : Colors.transparent, ), ], @@ -239,10 +234,8 @@ class MobileSidebar extends StatelessWidget { final kBarHeight = 3.0; Widget _menuIconBuilder(BuildContext context) { - if (menuButtonBuilder != null) { - return menuButtonBuilder(context); - } - return IconButton( + return menuButtonBuilder(context); + return IconButton( icon: Icon(Icons.menu), onPressed: () => _scaffoldKey.currentState.openDrawer(), ); @@ -250,22 +243,16 @@ class MobileSidebar extends StatelessWidget { Widget _searchBuilder(BuildContext context, bool showDrawer) { if (showDrawer) { - if (searchIconBuilder != null) { - return searchIconBuilder(context); - } - return IconButton( + return searchIconBuilder(context); + return IconButton( icon: Icon(Icons.search), onPressed: () { - if (isSearchChanged != null) { - isSearchChanged(!isSearching); - } - }, + isSearchChanged(!isSearching); + }, ); } - if (searchBarBuilder != null) { - return searchBarBuilder(context, searchChanged); - } - const kSearchBarWidth = 225.0; + return searchBarBuilder(context, searchChanged); + const kSearchBarWidth = 225.0; return Container( width: kSearchBarWidth, @@ -289,10 +276,8 @@ class MobileSidebar extends StatelessWidget { onTap: isSearching ? null : () { - if (isSearchChanged != null) { - isSearchChanged(!isSearching); - } - }, + isSearchChanged(!isSearching); + }, ), ), ); @@ -345,10 +330,10 @@ class MobileSidebar extends StatelessWidget { ], ), _divider, - if (ctaBuilder != null) ...[ - ctaBuilder(context), - _divider, - ], + ...[ + ctaBuilder(context), + _divider, + ], ], ), ), diff --git a/deprecated/navigation_rail/example/lib/main.dart b/deprecated/navigation_rail/example/lib/main.dart index 1b33db1..552688b 100644 --- a/deprecated/navigation_rail/example/lib/main.dart +++ b/deprecated/navigation_rail/example/lib/main.dart @@ -10,7 +10,7 @@ class MyApp extends StatelessWidget { debugShowCheckedModeBanner: false, title: 'NavigationRail Demo', theme: _theme(ThemeData.light().copyWith( - accentColor: Colors.red, + colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.red), )), darkTheme: ThemeData.dark(), home: Directionality( @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget { appBarTheme: base.appBarTheme.copyWith(elevation: 0.0), floatingActionButtonTheme: base.floatingActionButtonTheme.copyWith( elevation: 2.0, - backgroundColor: base.accentColor, + backgroundColor: base.colorScheme.secondary, ), ); } @@ -96,19 +96,19 @@ class _MyHomePageState extends State { ), tabs: [ BottomNavigationBarItem( - title: Text("Folders"), + label: Text("Folders"), icon: Icon(Icons.folder), ), BottomNavigationBarItem( - title: Text("History"), + label: Text("History"), icon: Icon(Icons.history), ), BottomNavigationBarItem( - title: Text("Gallery"), + label: Text("Gallery"), icon: Icon(Icons.photo_library), ), BottomNavigationBarItem( - title: Text("Camera"), + label: Text("Camera"), icon: Icon(Icons.camera), ), ], diff --git a/deprecated/navigation_rail/lib/navigation_rail.dart b/deprecated/navigation_rail/lib/navigation_rail.dart index 4ab30d7..8c98710 100644 --- a/deprecated/navigation_rail/lib/navigation_rail.dart +++ b/deprecated/navigation_rail/lib/navigation_rail.dart @@ -144,10 +144,10 @@ class NavRail extends StatelessWidget { backgroundColor: Theme.of(context).scaffoldBackgroundColor, minWidth: isDense ? _denseRailSize : _railSize, selectedIconTheme: IconThemeData( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), selectedLabelTextStyle: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), unselectedIconTheme: IconThemeData( color: Colors.grey, @@ -157,7 +157,7 @@ class NavRail extends StatelessWidget { onDestinationSelected: (val) => onTap(val), destinations: tabs .map((e) => NavigationRailDestination( - label: e.title, + label: e.label, icon: e.icon, )) .toList(), @@ -169,15 +169,15 @@ class NavRail extends StatelessWidget { child: SafeArea( child: Column( children: [ - if (drawerHeaderBuilder != null) ...[ - drawerHeaderBuilder(context), - ], + ...[ + drawerHeaderBuilder(context), + ], if (showTabs) ...[ Expanded(child: buildRail(context, true)), ], - if (drawerFooterBuilder != null) ...[ - drawerFooterBuilder(context), - ], + ...[ + drawerFooterBuilder(context), + ], ], ), ), diff --git a/deprecated/project_gen/lib/src/constants.dart b/deprecated/project_gen/lib/src/constants.dart index cfc5f45..ba692c7 100644 --- a/deprecated/project_gen/lib/src/constants.dart +++ b/deprecated/project_gen/lib/src/constants.dart @@ -114,15 +114,13 @@ class MyApp extends StatelessWidget { """; String buildCustomColors(List colors) { - if (colors != null) { - final sb = StringBuffer(); - for (var color in colors) { - String _name = ReCase(color.name).camelCase; - int _value = color.color; - sb.writeln(' static Color get $_name => const Color($_value);'); - } - return sb.toString(); + final sb = StringBuffer(); + for (var color in colors) { + String _name = ReCase(color.name).camelCase; + int _value = color.color; + sb.writeln(' static Color get $_name => const Color($_value);'); } + return sb.toString(); return ''; } @@ -134,52 +132,42 @@ import 'package:flutter/material.dart'; bool isDark(BuildContext context) => Theme.of(context).brightness == Brightness.dark; -ThemeMode get themeMode => ${(project?.themeMode ?? ThemeMode.system).toString()}; +ThemeMode get themeMode => ${(project.themeMode ?? ThemeMode.system).toString()}; """); - sb.writeln(_writeProjectTheme(project?.lightTheme, 'LightTheme', true)); - sb.writeln(_writeProjectTheme(project?.darkTheme, 'DarkTheme', false)); + sb.writeln(_writeProjectTheme(project.lightTheme, 'LightTheme', true)); + sb.writeln(_writeProjectTheme(project.darkTheme, 'DarkTheme', false)); return sb.toString(); } String _writeProjectTheme(ProjectTheme theme, String name, bool isLight) { - if (theme == null) { - return """ -class $name { - $name._(); - - static ThemeData get data => ThemeData.${isLight ? 'light' : 'dark'}(); - -} - """; - } ThemeData _base = isLight ? ThemeData.light() : ThemeData.dark(); return """ class $name { $name._(); static ThemeData get data => ThemeData( - brightness: ${theme?.lightBrightness ?? isLight ? 'Brightness.light' : 'Brightness.dark'}, + brightness: ${theme.lightBrightness ?? isLight ? 'Brightness.light' : 'Brightness.dark'}, visualDensity: VisualDensity.adaptivePlatformDensity, textTheme: ThemeData.${isLight ? 'light' : 'dark'}().textTheme ).copyWith( - primaryColor: const Color(${_getColor(theme?.primaryColor, _base.primaryColor)}), - accentColor: const Color(${_getColor(theme?.accentColor, _base.accentColor)}), + primaryColor: const Color(${_getColor(theme.primaryColor, _base.primaryColor)}), + accentColor: const Color(${_getColor(theme.accentColor, _base.colorScheme.secondary)}), floatingActionButtonTheme: ThemeData.${isLight ? 'light' : 'dark'}().floatingActionButtonTheme.copyWith( - backgroundColor: const Color(${_getColor(theme?.floatingActionButtonBackgroundColor, _base.floatingActionButtonTheme.backgroundColor)}), - foregroundColor: const Color(${_getColor(theme?.floatingActionButtonForegroundColor, _base.floatingActionButtonTheme.foregroundColor)}), + backgroundColor: const Color(${_getColor(theme.floatingActionButtonBackgroundColor, _base.floatingActionButtonTheme.backgroundColor)}), + foregroundColor: const Color(${_getColor(theme.floatingActionButtonForegroundColor, _base.floatingActionButtonTheme.foregroundColor)}), ), - scaffoldBackgroundColor: const Color(${_getColor(theme?.scaffoldBackgroundColor, _base.scaffoldBackgroundColor)}), + scaffoldBackgroundColor: const Color(${_getColor(theme.scaffoldBackgroundColor, _base.scaffoldBackgroundColor)}), appBarTheme: ThemeData.${isLight ? 'light' : 'dark'}().appBarTheme, ); -${buildCustomColors(theme?.customColors)} +${buildCustomColors(theme.customColors)} } """; } int _getColor(int value, Color fallback) { - return value ?? fallback?.value ?? Colors.blue.value; + return value ?? fallback.value ?? Colors.blue.value; } diff --git a/deprecated/project_gen/lib/src/files/mobile.dart b/deprecated/project_gen/lib/src/files/mobile.dart index 4b96ebe..a4f3816 100644 --- a/deprecated/project_gen/lib/src/files/mobile.dart +++ b/deprecated/project_gen/lib/src/files/mobile.dart @@ -101,10 +101,8 @@ Future _writeFilesDir( if (!_dir.existsSync()) { _dir.createSync(recursive: true); } - if (file?.children != null) { - await _writeFilesDir(file.children, path, base); - } - } + await _writeFilesDir(file.children, path, base); + } } } diff --git a/deprecated/project_gen/lib/src/project/project.freezed.dart b/deprecated/project_gen/lib/src/project/project.freezed.dart index 0ef9023..547f304 100644 --- a/deprecated/project_gen/lib/src/project/project.freezed.dart +++ b/deprecated/project_gen/lib/src/project/project.freezed.dart @@ -166,9 +166,6 @@ class _$FlutterProjectCopyWithImpl<$Res> @override $ProjectThemeCopyWith<$Res> get lightTheme { - if (_value.lightTheme == null) { - return null; - } return $ProjectThemeCopyWith<$Res>(_value.lightTheme, (value) { return _then(_value.copyWith(lightTheme: value)); }); @@ -176,9 +173,6 @@ class _$FlutterProjectCopyWithImpl<$Res> @override $ProjectThemeCopyWith<$Res> get darkTheme { - if (_value.darkTheme == null) { - return null; - } return $ProjectThemeCopyWith<$Res>(_value.darkTheme, (value) { return _then(_value.copyWith(darkTheme: value)); }); @@ -298,16 +292,7 @@ class _$_FlutterProject this.themeMode, this.canvasZoom = 0, this.canvasOffsetDx = 0, - this.canvasOffsetDy = 0}) - : assert(name != null), - assert(org != null), - assert(description != null), - assert(useSwift != null), - assert(useKotlin != null), - assert(targets != null), - assert(canvasZoom != null), - assert(canvasOffsetDx != null), - assert(canvasOffsetDy != null); + this.canvasOffsetDy = 0}); factory _$_FlutterProject.fromJson(Map json) => _$_$_FlutterProjectFromJson(json); diff --git a/deprecated/project_gen/lib/src/project/theme.freezed.dart b/deprecated/project_gen/lib/src/project/theme.freezed.dart index ed22692..7e497e3 100644 --- a/deprecated/project_gen/lib/src/project/theme.freezed.dart +++ b/deprecated/project_gen/lib/src/project/theme.freezed.dart @@ -750,9 +750,6 @@ class _$_CustomGradient double endY, TileMode tileMode), }) { - assert($default != null); - assert(radial != null); - assert(linear != null); return $default(name, colors); } @@ -781,11 +778,8 @@ class _$_CustomGradient TileMode tileMode), @required Result orElse(), }) { - assert(orElse != null); - if ($default != null) { - return $default(name, colors); - } - return orElse(); + return $default(name, colors); + return orElse(); } @override @@ -795,9 +789,6 @@ class _$_CustomGradient @required Result radial(CustomRadialGradient value), @required Result linear(CustomLinearGradient value), }) { - assert($default != null); - assert(radial != null); - assert(linear != null); return $default(this); } @@ -809,11 +800,8 @@ class _$_CustomGradient Result linear(CustomLinearGradient value), @required Result orElse(), }) { - assert(orElse != null); - if ($default != null) { - return $default(this); - } - return orElse(); + return $default(this); + return orElse(); } @override @@ -1006,9 +994,6 @@ class _$CustomRadialGradient double endY, TileMode tileMode), }) { - assert($default != null); - assert(radial != null); - assert(linear != null); return radial(name, stops, colors, radius, alignX, alignY, focalX, focalY); } @@ -1037,12 +1022,9 @@ class _$CustomRadialGradient TileMode tileMode), @required Result orElse(), }) { - assert(orElse != null); - if (radial != null) { - return radial( - name, stops, colors, radius, alignX, alignY, focalX, focalY); - } - return orElse(); + return radial( + name, stops, colors, radius, alignX, alignY, focalX, focalY); + return orElse(); } @override @@ -1052,9 +1034,6 @@ class _$CustomRadialGradient @required Result radial(CustomRadialGradient value), @required Result linear(CustomLinearGradient value), }) { - assert($default != null); - assert(radial != null); - assert(linear != null); return radial(this); } @@ -1066,11 +1045,8 @@ class _$CustomRadialGradient Result linear(CustomLinearGradient value), @required Result orElse(), }) { - assert(orElse != null); - if (radial != null) { - return radial(this); - } - return orElse(); + return radial(this); + return orElse(); } @override @@ -1288,9 +1264,6 @@ class _$CustomLinearGradient double endY, TileMode tileMode), }) { - assert($default != null); - assert(radial != null); - assert(linear != null); return linear( name, stops, colors, radius, startX, startY, endX, endY, tileMode); } @@ -1320,12 +1293,9 @@ class _$CustomLinearGradient TileMode tileMode), @required Result orElse(), }) { - assert(orElse != null); - if (linear != null) { - return linear( - name, stops, colors, radius, startX, startY, endX, endY, tileMode); - } - return orElse(); + return linear( + name, stops, colors, radius, startX, startY, endX, endY, tileMode); + return orElse(); } @override @@ -1335,9 +1305,6 @@ class _$CustomLinearGradient @required Result radial(CustomRadialGradient value), @required Result linear(CustomLinearGradient value), }) { - assert($default != null); - assert(radial != null); - assert(linear != null); return linear(this); } @@ -1349,11 +1316,8 @@ class _$CustomLinearGradient Result linear(CustomLinearGradient value), @required Result orElse(), }) { - assert(orElse != null); - if (linear != null) { - return linear(this); - } - return orElse(); + return linear(this); + return orElse(); } @override diff --git a/deprecated/project_gen/lib/src/project/widget.freezed.dart b/deprecated/project_gen/lib/src/project/widget.freezed.dart index 9ba814c..b4de31d 100644 --- a/deprecated/project_gen/lib/src/project/widget.freezed.dart +++ b/deprecated/project_gen/lib/src/project/widget.freezed.dart @@ -196,10 +196,7 @@ class _$ProjectScreen with DiagnosticableTreeMixin implements ProjectScreen { this.dx, this.dy, this.width, - this.height}) - : assert(className != null), - assert(isStateful != null), - assert(route != null); + this.height}); factory _$ProjectScreen.fromJson(Map json) => _$_$ProjectScreenFromJson(json); diff --git a/deprecated/project_gen/lib/src/project_files.dart b/deprecated/project_gen/lib/src/project_files.dart index 64a658c..bca920b 100644 --- a/deprecated/project_gen/lib/src/project_files.dart +++ b/deprecated/project_gen/lib/src/project_files.dart @@ -106,12 +106,8 @@ class ProjectFile extends ProjectFileBase { Future getFileData() async { List _data; - if (content.value != null) { - _data = content.value; - } else if (readAsBytes != null) { - _data = await readAsBytes; - } - return FileData( + _data = content.value; + return FileData( _data, _data.length, filename, diff --git a/deprecated/responsive_scaffold/example/lib/examples/layout.dart b/deprecated/responsive_scaffold/example/lib/examples/layout.dart index e4f0350..2f92feb 100644 --- a/deprecated/responsive_scaffold/example/lib/examples/layout.dart +++ b/deprecated/responsive_scaffold/example/lib/examples/layout.dart @@ -74,7 +74,7 @@ class LayoutExample extends StatelessWidget { ), floatingActionButton: FloatingActionButton( child: Icon(Icons.add), - backgroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).colorScheme.secondary, onPressed: () {}, ), ); diff --git a/deprecated/responsive_scaffold/example/lib/examples/list.dart b/deprecated/responsive_scaffold/example/lib/examples/list.dart index 3289698..a6b0cbb 100644 --- a/deprecated/responsive_scaffold/example/lib/examples/list.dart +++ b/deprecated/responsive_scaffold/example/lib/examples/list.dart @@ -53,7 +53,7 @@ class _ListExampleState extends State { title: Text("App Bar"), ), ], - itemCount: _items?.length ?? 0, + itemCount: _items.length ?? 0, itemBuilder: (BuildContext context, int index) { final i = _items[index]; return ListTile( diff --git a/deprecated/responsive_scaffold/example/lib/main.dart b/deprecated/responsive_scaffold/example/lib/main.dart index a535598..cc9086f 100644 --- a/deprecated/responsive_scaffold/example/lib/main.dart +++ b/deprecated/responsive_scaffold/example/lib/main.dart @@ -22,16 +22,14 @@ void _setTargetPlatformForDesktop() { } else if (Platform.isLinux || Platform.isWindows) { targetPlatform = TargetPlatform.android; } - if (targetPlatform != null) { - debugDefaultTargetPlatformOverride = targetPlatform; - } + debugDefaultTargetPlatformOverride = targetPlatform; } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - theme: ThemeData.light().copyWith(accentColor: Colors.red), + theme: ThemeData.light().copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.red)), debugShowCheckedModeBanner: false, home: HomePage(), ); diff --git a/deprecated/responsive_scaffold/lib/templates/3-column/common/details.dart b/deprecated/responsive_scaffold/lib/templates/3-column/common/details.dart index 891cea5..cd25a03 100644 --- a/deprecated/responsive_scaffold/lib/templates/3-column/common/details.dart +++ b/deprecated/responsive_scaffold/lib/templates/3-column/common/details.dart @@ -51,16 +51,15 @@ class DetailsView extends StatelessWidget { ), ], ), - if (_details?.title != null) - Expanded( - child: Center(child: _details.title), - ), + Expanded( + child: Center(child: _details.title), + ), ], ), - actions: _details?.actions, + actions: _details.actions, ), body: _details.child, - bottomNavigationBar: _details?.bottomAppBar, + bottomNavigationBar: _details.bottomAppBar, ); } } diff --git a/deprecated/responsive_scaffold/lib/templates/3-column/three_column_navigation.dart b/deprecated/responsive_scaffold/lib/templates/3-column/three_column_navigation.dart index 37f702a..53019bc 100644 --- a/deprecated/responsive_scaffold/lib/templates/3-column/three_column_navigation.dart +++ b/deprecated/responsive_scaffold/lib/templates/3-column/three_column_navigation.dart @@ -85,9 +85,9 @@ class _ThreeColumnNavigationState extends State { Container( width: 300, child: Scaffold( - backgroundColor: widget?.backgroundColor, + backgroundColor: widget.backgroundColor, appBar: AppBar( - title: widget?.title, + title: widget.title, leading: IconButton( icon: Icon(widget.expandedIconData), onPressed: () { @@ -111,7 +111,7 @@ class _ThreeColumnNavigationState extends State { } }, ), - bottomNavigationBar: widget?.bottomAppBar, + bottomNavigationBar: widget.bottomAppBar, ), ), Container( @@ -164,7 +164,7 @@ class _ThreeColumnNavigationState extends State { }, ), bottomNavigationBar: - widget.sections[_sectionIndex]?.bottomAppBar, + widget.sections[_sectionIndex].bottomAppBar, ), ), Expanded( @@ -221,7 +221,7 @@ class _ThreeColumnNavigationState extends State { }, ), appBar: AppBar( - title: widget.sections[_sectionIndex]?.label, + title: widget.sections[_sectionIndex].label, ), body: SectionList( controller: controller, @@ -250,7 +250,7 @@ class _ThreeColumnNavigationState extends State { } }, ), - bottomNavigationBar: widget.sections[_sectionIndex]?.bottomAppBar, + bottomNavigationBar: widget.sections[_sectionIndex].bottomAppBar, ); }, ); diff --git a/deprecated/responsive_scaffold/lib/templates/layout/scaffold.dart b/deprecated/responsive_scaffold/lib/templates/layout/scaffold.dart index 343c849..401e95d 100644 --- a/deprecated/responsive_scaffold/lib/templates/layout/scaffold.dart +++ b/deprecated/responsive_scaffold/lib/templates/layout/scaffold.dart @@ -46,16 +46,16 @@ class ResponsiveScaffold extends StatelessWidget { children: [ Row( children: [ - if (drawer != null) ...[ - SizedBox( - width: _drawerWidth, - child: Drawer( - child: SafeArea( - child: drawer, - ), + ...[ + SizedBox( + width: _drawerWidth, + child: Drawer( + child: SafeArea( + child: drawer, ), ), - ], + ), + ], Expanded( child: Scaffold( key: scaffoldKey, @@ -64,9 +64,9 @@ class ResponsiveScaffold extends StatelessWidget { automaticallyImplyLeading: false, title: title, actions: [ - if (trailing != null) ...[ - trailing, - ], + ...[ + trailing, + ], ], ), body: Row( @@ -74,30 +74,30 @@ class ResponsiveScaffold extends StatelessWidget { Expanded( child: body ?? Container(), ), - if (endDrawer != null) ...[ - Container( - width: _drawerWidth, - child: Drawer( - elevation: 3.0, - child: SafeArea( - child: endDrawer, - ), + ...[ + Container( + width: _drawerWidth, + child: Drawer( + elevation: 3.0, + child: SafeArea( + child: endDrawer, ), ), - ], + ), + ], ], ), ), ), ], ), - if (floatingActionButton != null) ...[ - Positioned( - top: 100.0, - left: _drawerWidth - 30, - child: floatingActionButton, - ) - ], + ...[ + Positioned( + top: 100.0, + left: _drawerWidth - 30, + child: floatingActionButton, + ) + ], ], ), ); @@ -105,9 +105,7 @@ class ResponsiveScaffold extends StatelessWidget { if (constraints.maxWidth >= kTabletBreakpoint) { return Scaffold( key: scaffoldKey, - drawer: drawer == null - ? null - : Drawer( + drawer: Drawer( child: SafeArea( child: drawer, ), @@ -118,9 +116,9 @@ class ResponsiveScaffold extends StatelessWidget { title: title, leading: _MenuButton(iconData: menuIcon), actions: [ - if (trailing != null) ...[ - trailing, - ], + ...[ + trailing, + ], ], ), body: SafeArea( @@ -133,26 +131,26 @@ class ResponsiveScaffold extends StatelessWidget { Expanded( child: body ?? Container(), ), - if (endDrawer != null) ...[ - Container( - width: _drawerWidth, - child: Drawer( - elevation: 3.0, - child: SafeArea( - child: endDrawer, - ), + ...[ + Container( + width: _drawerWidth, + child: Drawer( + elevation: 3.0, + child: SafeArea( + child: endDrawer, ), ), - ], + ), + ], ], ), - if (floatingActionButton != null) ...[ - Positioned( - top: 10.0, - left: 10.0, - child: floatingActionButton, - ) - ], + ...[ + Positioned( + top: 10.0, + left: 10.0, + child: floatingActionButton, + ) + ], ], ), ), @@ -160,16 +158,12 @@ class ResponsiveScaffold extends StatelessWidget { } return Scaffold( key: scaffoldKey, - drawer: drawer == null - ? null - : Drawer( + drawer: Drawer( child: SafeArea( child: drawer, ), ), - endDrawer: endDrawer == null - ? null - : Drawer( + endDrawer: Drawer( child: SafeArea( child: endDrawer, ), @@ -180,12 +174,12 @@ class ResponsiveScaffold extends StatelessWidget { leading: _MenuButton(iconData: menuIcon), title: title, actions: [ - if (trailing != null) ...[ - trailing, - ], - if (endDrawer != null) ...[ - _OptionsButton(iconData: endIcon), - ] + ...[ + trailing, + ], + ...[ + _OptionsButton(iconData: endIcon), + ] ], ), body: body, diff --git a/deprecated/responsive_scaffold/lib/templates/list/responsive_list.dart b/deprecated/responsive_scaffold/lib/templates/list/responsive_list.dart index 3019a37..312586b 100644 --- a/deprecated/responsive_scaffold/lib/templates/list/responsive_list.dart +++ b/deprecated/responsive_scaffold/lib/templates/list/responsive_list.dart @@ -214,7 +214,7 @@ class ResponsiveListScaffold extends StatelessWidget { persistentFooterButtons: persistentFooterButtons, floatingActionButtonAnimator: floatingActionButtonAnimator, resizeToAvoidBottomInset: resizeToAvoidBottomInset, - resizeToAvoidBottomPadding: resizeToAvoidBottomPadding, + resizeToAvoidBottomInset: resizeToAvoidBottomPadding, primary: primary, // extendBody: extendBody, backgroundColor: backgroundColor, diff --git a/deprecated/responsive_scaffold/lib/templates/list/views/mobile.dart b/deprecated/responsive_scaffold/lib/templates/list/views/mobile.dart index f6c74fd..14a8d41 100644 --- a/deprecated/responsive_scaffold/lib/templates/list/views/mobile.dart +++ b/deprecated/responsive_scaffold/lib/templates/list/views/mobile.dart @@ -69,11 +69,10 @@ class MobileView extends StatelessWidget { ..addAll(slivers ?? []) ..add(Builder( builder: (BuildContext context) { - if (childDelagate?.estimatedChildCount == null && nullItems != null) + if (childDelagate.estimatedChildCount == null) return SliverFillRemaining(child: nullItems); - if (childDelagate?.estimatedChildCount != null && - childDelagate.estimatedChildCount == 0 && - emptyItems != null) + if (childDelagate.estimatedChildCount != null && + childDelagate.estimatedChildCount == 0) return SliverFillRemaining(child: emptyItems); return SliverList( delegate: SliverChildBuilderDelegate( @@ -101,7 +100,7 @@ class MobileView extends StatelessWidget { ), ); }, - childCount: childDelagate?.estimatedChildCount ?? 0, + childCount: childDelagate.estimatedChildCount ?? 0, addAutomaticKeepAlives: false, addRepaintBoundaries: false, addSemanticIndexes: false, diff --git a/deprecated/responsive_scaffold/lib/templates/list/views/tablet.dart b/deprecated/responsive_scaffold/lib/templates/list/views/tablet.dart index 79aae04..23cb4b6 100644 --- a/deprecated/responsive_scaffold/lib/templates/list/views/tablet.dart +++ b/deprecated/responsive_scaffold/lib/templates/list/views/tablet.dart @@ -171,40 +171,38 @@ class _TabletViewState extends State { body: Flex( direction: Axis.horizontal, children: [ - widget?.sideMenu ?? Container(), + widget.sideMenu ?? Container(), Flexible( flex: widget.flexListView, child: Scaffold( - key: widget?.scaffoldkey, - floatingActionButton: widget?.floatingActionButton, + key: widget.scaffoldkey, + floatingActionButton: widget.floatingActionButton, floatingActionButtonLocation: - widget?.floatingActionButtonLocation, - bottomNavigationBar: widget?.bottomNavigationBar, - bottomSheet: widget?.bottomSheet, - persistentFooterButtons: widget?.persistentFooterButtons, + widget.floatingActionButtonLocation, + bottomNavigationBar: widget.bottomNavigationBar, + bottomSheet: widget.bottomSheet, + persistentFooterButtons: widget.persistentFooterButtons, floatingActionButtonAnimator: - widget?.floatingActionButtonAnimator, - resizeToAvoidBottomInset: widget?.resizeToAvoidBottomInset, - resizeToAvoidBottomPadding: widget?.resizeToAvoidBottomPadding, - primary: widget?.primary, + widget.floatingActionButtonAnimator, + resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset, + resizeToAvoidBottomInset: widget.resizeToAvoidBottomPadding, + primary: widget.primary, // extendBody: extendBody, - backgroundColor: widget?.backgroundColor, - drawer: widget?.drawer, - endDrawer: widget?.endDrawer, - appBar: widget?.appBar, + backgroundColor: widget.backgroundColor, + drawer: widget.drawer, + endDrawer: widget.endDrawer, + appBar: widget.appBar, body: CustomScrollView( slivers: [] ..addAll(widget.slivers ?? []) ..add(Builder( builder: (BuildContext context) { SliverChildDelegate _childDelagate = - widget?.childDelagate; - if (_childDelagate?.estimatedChildCount == null && - widget?.nullItems != null) + widget.childDelagate; + if (_childDelagate.estimatedChildCount == null) return SliverFillRemaining(child: widget.nullItems); - if (_childDelagate?.estimatedChildCount != null && - _childDelagate.estimatedChildCount == 0 && - widget?.emptyItems != null) + if (_childDelagate.estimatedChildCount != null && + _childDelagate.estimatedChildCount == 0) return SliverFillRemaining(child: widget.emptyItems); return SliverList( delegate: SliverChildBuilderDelegate( @@ -224,7 +222,7 @@ class _TabletViewState extends State { ? Theme.of(context) .chipTheme .disabledColor - : widget?.backgroundColor, + : widget.backgroundColor, padding: const EdgeInsets.symmetric(vertical: 8.0), child: _childDelagate.build(context, index), @@ -233,7 +231,7 @@ class _TabletViewState extends State { ), ); }, - childCount: _childDelagate?.estimatedChildCount ?? 0, + childCount: _childDelagate.estimatedChildCount ?? 0, addAutomaticKeepAlives: false, addRepaintBoundaries: false, addSemanticIndexes: false, @@ -246,12 +244,11 @@ class _TabletViewState extends State { Flexible( flex: widget.flexDetailView, child: new _DetailView( - detailScaffoldKey: widget?.detailScaffoldKey, - details: _index == null || - _index > widget.childDelagate.estimatedChildCount - 1 + detailScaffoldKey: widget.detailScaffoldKey, + details: _index > widget.childDelagate.estimatedChildCount - 1 ? null : widget.detailBuilder(context, _index, true), - itemNotSelected: widget?.itemNotSelected, + itemNotSelected: widget.itemNotSelected, ), ), ], diff --git a/deprecated/scaffold_tab_bar/example/lib/main.dart b/deprecated/scaffold_tab_bar/example/lib/main.dart index 04be967..fa1d9dc 100644 --- a/deprecated/scaffold_tab_bar/example/lib/main.dart +++ b/deprecated/scaffold_tab_bar/example/lib/main.dart @@ -18,21 +18,21 @@ class MyApp extends StatelessWidget { screen: Screen1(), tab: BottomNavigationBarItem( icon: Icon(Icons.home), - title: Text('Home'), + label: Text('Home'), ), ), ScreenTab( screen: Screen2(), tab: BottomNavigationBarItem( icon: Icon(Icons.event), - title: Text('Calendar'), + label: Text('Calendar'), ), ), ScreenTab( screen: Screen3(), tab: BottomNavigationBarItem( icon: Icon(Icons.search), - title: Text('Search'), + label: Text('Search'), ), ), ], diff --git a/deprecated/scaffold_tab_bar/lib/src/tab_bar.dart b/deprecated/scaffold_tab_bar/lib/src/tab_bar.dart index 2fb96b7..df87260 100644 --- a/deprecated/scaffold_tab_bar/lib/src/tab_bar.dart +++ b/deprecated/scaffold_tab_bar/lib/src/tab_bar.dart @@ -61,7 +61,7 @@ class _ScaffoldTabBarState extends State { _screens = widget.children; _currentIndex = 0; for (var screen in _screens) { - _keys.add(GlobalKey(debugLabel: screen?.debugLabel)); + _keys.add(GlobalKey(debugLabel: screen.debugLabel)); } } @@ -98,23 +98,23 @@ class _ScaffoldTabBarState extends State { )); } return Scaffold( - backgroundColor: widget?.backgroundColor, - key: widget?.scaffoldKey, - drawer: widget?.drawer, - endDrawer: widget?.endDrawer, - persistentFooterButtons: widget?.persistentFooterButtons, - floatingActionButton: widget?.floatingActionButton, - floatingActionButtonAnimator: widget?.floatingActionButtonAnimator, - floatingActionButtonLocation: widget?.floatingActionButtonLocation, + backgroundColor: widget.backgroundColor, + key: widget.scaffoldKey, + drawer: widget.drawer, + endDrawer: widget.endDrawer, + persistentFooterButtons: widget.persistentFooterButtons, + floatingActionButton: widget.floatingActionButton, + floatingActionButtonAnimator: widget.floatingActionButtonAnimator, + floatingActionButtonLocation: widget.floatingActionButtonLocation, body: IndexedStack( index: _currentIndex, children: _children, ), bottomNavigationBar: BottomNavigationBar( - type: widget?.bottomNavigationBarType, + type: widget.bottomNavigationBarType, currentIndex: _currentIndex, onTap: (val) => _onTap(val, context), - backgroundColor: widget?.bottomNavigationBarBackgroundColor ?? + backgroundColor: widget.bottomNavigationBarBackgroundColor ?? Theme.of(context).scaffoldBackgroundColor, items: _screens.map((s) => s.tab).toList(), ), diff --git a/deprecated/settings_manager/example/lib/main.dart b/deprecated/settings_manager/example/lib/main.dart index 3d594f7..013bbe7 100644 --- a/deprecated/settings_manager/example/lib/main.dart +++ b/deprecated/settings_manager/example/lib/main.dart @@ -52,7 +52,7 @@ class _MyHomePageState extends State { ), Text( '${snapshot.data}', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), ], ), diff --git a/deprecated/settings_manager/packages/settings_gen/lib/src/template/comma_list.dart b/deprecated/settings_manager/packages/settings_gen/lib/src/template/comma_list.dart index ac3bbcc..f4c8579 100644 --- a/deprecated/settings_manager/packages/settings_gen/lib/src/template/comma_list.dart +++ b/deprecated/settings_manager/packages/settings_gen/lib/src/template/comma_list.dart @@ -1,7 +1,7 @@ import 'package:settings_gen/src/template/util.dart'; class CommaList { - CommaList(this.templates) : assert(templates != null); + CommaList(this.templates); final List templates; @@ -11,10 +11,7 @@ class CommaList { } class SurroundedCommaList { - SurroundedCommaList(this.prefix, this.suffix, this.templates) - : assert(prefix != null), - assert(suffix != null), - assert(templates != null); + SurroundedCommaList(this.prefix, this.suffix, this.templates); final String prefix; final String suffix; diff --git a/deprecated/settings_manager/packages/settings_gen/lib/src/template/params.dart b/deprecated/settings_manager/packages/settings_gen/lib/src/template/params.dart index c5eb655..e12a6b9 100644 --- a/deprecated/settings_manager/packages/settings_gen/lib/src/template/params.dart +++ b/deprecated/settings_manager/packages/settings_gen/lib/src/template/params.dart @@ -11,9 +11,7 @@ class ParamTemplate { String get metadata => hasRequiredAnnotation ? '@required ' : ''; @override - String toString() => defaultValue == null - ? '$metadata$type $name' - : '$type $name = $defaultValue'; + String toString() => '$type $name = $defaultValue'; } class TypeParamTemplate { @@ -23,7 +21,7 @@ class TypeParamTemplate { String get asArgument => name; @override - String toString() => bound == null ? name : '$name extends $bound'; + String toString() => '$name extends $bound'; } class NamedArgTemplate { diff --git a/deprecated/settings_manager/packages/settings_gen/lib/src/type_names.dart b/deprecated/settings_manager/packages/settings_gen/lib/src/type_names.dart index e1dc4fd..d8332f1 100644 --- a/deprecated/settings_manager/packages/settings_gen/lib/src/type_names.dart +++ b/deprecated/settings_manager/packages/settings_gen/lib/src/type_names.dart @@ -23,10 +23,8 @@ class LibraryScopedNameFinder { Map _namesByElement; Map get namesByElement { - if (_namesByElement != null) { - return _namesByElement; - } - + return _namesByElement; + _namesByElement = {}; // Add all of this library's type-defining elements to the name map diff --git a/deprecated/sheet_music/lib/models/step.dart b/deprecated/sheet_music/lib/models/step.dart index 2d06853..6f89f21 100644 --- a/deprecated/sheet_music/lib/models/step.dart +++ b/deprecated/sheet_music/lib/models/step.dart @@ -5,9 +5,6 @@ enum Step { DO, RE, MI, FA, SOL, LA, TI } Step updateStep(String scale, String pitch) { // print("Scale: $scale, Pitch: $pitch"); - if (pitch == null) return Step.DO; - if (scale == null) return Step.DO; - final PossibleScales? _scale = ScaleInfo.parse(scale).scale; switch (_scale) { diff --git a/deprecated/sheet_music/lib/util/pitch_asset.dart b/deprecated/sheet_music/lib/util/pitch_asset.dart index 2d96b2f..8ec66e1 100644 --- a/deprecated/sheet_music/lib/util/pitch_asset.dart +++ b/deprecated/sheet_music/lib/util/pitch_asset.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import '../models/scale.dart'; import 'assets.dart'; diff --git a/deprecated/storyboard/example/lib/examples/complete_custom_lanes_builder.dart b/deprecated/storyboard/example/lib/examples/complete_custom_lanes_builder.dart index 246622b..17dc708 100644 --- a/deprecated/storyboard/example/lib/examples/complete_custom_lanes_builder.dart +++ b/deprecated/storyboard/example/lib/examples/complete_custom_lanes_builder.dart @@ -18,8 +18,7 @@ class MyApp extends StatelessWidget { margin: const EdgeInsets.all(4.0), color: RandomColor(title.hashCode).randomColor(), child: Stack( - overflow: Overflow.visible, - children: [ + clipBehavior: Clip.none, children: [ child, Positioned( left: -50, @@ -94,7 +93,7 @@ Widget _generateScreen({ return Scaffold( appBar: AppBar(title: title), backgroundColor: color, - body: args == null ? null : Center(child: Text(args.toString())), + body: Center(child: Text(args.toString())), floatingActionButton: fab, ); }, diff --git a/deprecated/storyboard/example/lib/examples/custom_lane_builder.dart b/deprecated/storyboard/example/lib/examples/custom_lane_builder.dart index b151fba..060b8fe 100644 --- a/deprecated/storyboard/example/lib/examples/custom_lane_builder.dart +++ b/deprecated/storyboard/example/lib/examples/custom_lane_builder.dart @@ -27,8 +27,7 @@ class MyApp extends StatelessWidget { margin: const EdgeInsets.all(4.0), color: RandomColor(title.hashCode).randomColor(), child: Stack( - overflow: Overflow.visible, - children: [ + clipBehavior: Clip.none, children: [ child, Positioned( left: -50, @@ -106,7 +105,7 @@ Widget _generateScreen({ return Scaffold( appBar: AppBar(title: title), backgroundColor: color, - body: args == null ? null : Center(child: Text(args.toString())), + body: Center(child: Text(args.toString())), floatingActionButton: fab, ); }, diff --git a/deprecated/storyboard/example/lib/examples/dynamic_screen_sizes.dart b/deprecated/storyboard/example/lib/examples/dynamic_screen_sizes.dart index a3abf41..4b18c85 100644 --- a/deprecated/storyboard/example/lib/examples/dynamic_screen_sizes.dart +++ b/deprecated/storyboard/example/lib/examples/dynamic_screen_sizes.dart @@ -47,7 +47,7 @@ Widget _generateScreen({ return Scaffold( appBar: AppBar(title: title), backgroundColor: color, - body: args == null ? null : Center(child: Text(args.toString())), + body: Center(child: Text(args.toString())), floatingActionButton: fab, ); }, diff --git a/deprecated/storyboard/example/lib/examples/material_app_example.dart b/deprecated/storyboard/example/lib/examples/material_app_example.dart index 810b149..990d9fa 100644 --- a/deprecated/storyboard/example/lib/examples/material_app_example.dart +++ b/deprecated/storyboard/example/lib/examples/material_app_example.dart @@ -79,7 +79,7 @@ Widget _generateScreen({ return Scaffold( appBar: AppBar(title: title), backgroundColor: color, - body: args == null ? null : Center(child: Text(args.toString())), + body: Center(child: Text(args.toString())), floatingActionButton: fab, ); }, diff --git a/deprecated/storyboard/example/lib/examples/storyboard_as_widget.dart b/deprecated/storyboard/example/lib/examples/storyboard_as_widget.dart index 38abfb6..89eefa1 100644 --- a/deprecated/storyboard/example/lib/examples/storyboard_as_widget.dart +++ b/deprecated/storyboard/example/lib/examples/storyboard_as_widget.dart @@ -37,7 +37,7 @@ Widget _generateScreen({ return Scaffold( appBar: AppBar(title: title), backgroundColor: color, - body: args == null ? null : Center(child: Text(args.toString())), + body: Center(child: Text(args.toString())), floatingActionButton: fab, ); }, diff --git a/deprecated/storyboard/example/lib/examples/widget_example.dart b/deprecated/storyboard/example/lib/examples/widget_example.dart index bab49a0..97cd2b0 100644 --- a/deprecated/storyboard/example/lib/examples/widget_example.dart +++ b/deprecated/storyboard/example/lib/examples/widget_example.dart @@ -38,7 +38,7 @@ Widget _generateScreen({ return Scaffold( appBar: AppBar(title: title), backgroundColor: color, - body: args == null ? null : Center(child: Text(args.toString())), + body: Center(child: Text(args.toString())), floatingActionButton: fab, ); }, diff --git a/deprecated/storyboard/example/lib/main.dart b/deprecated/storyboard/example/lib/main.dart index 3527fc5..6fe57d9 100644 --- a/deprecated/storyboard/example/lib/main.dart +++ b/deprecated/storyboard/example/lib/main.dart @@ -80,7 +80,7 @@ Widget _generateScreen({ return Scaffold( appBar: AppBar(title: title), backgroundColor: color, - body: args == null ? null : Center(child: Text(args.toString())), + body: Center(child: Text(args.toString())), floatingActionButton: fab, ); }, diff --git a/deprecated/storyboard/lib/src/media_query_observer.dart b/deprecated/storyboard/lib/src/media_query_observer.dart index f664c2c..cc71f25 100644 --- a/deprecated/storyboard/lib/src/media_query_observer.dart +++ b/deprecated/storyboard/lib/src/media_query_observer.dart @@ -23,13 +23,13 @@ class _MediaQueryObserverState extends State @override void initState() { - WidgetsBinding.instance?.addObserver(this); + WidgetsBinding.instance.addObserver(this); super.initState(); } @override void dispose() { - WidgetsBinding.instance?.removeObserver(this); + WidgetsBinding.instance.removeObserver(this); super.dispose(); } @@ -37,7 +37,7 @@ class _MediaQueryObserverState extends State Widget build(BuildContext context) { return MediaQuery( data: widget.data ?? - MediaQueryData.fromWindow(WidgetsBinding.instance!.window), + MediaQueryData.fromView(WidgetsBinding.instance.window), child: widget.child, ); } diff --git a/deprecated/storyboard/lib/src/nested_app.dart b/deprecated/storyboard/lib/src/nested_app.dart index c7f6351..b11493e 100644 --- a/deprecated/storyboard/lib/src/nested_app.dart +++ b/deprecated/storyboard/lib/src/nested_app.dart @@ -38,7 +38,7 @@ class _NestedAppState extends State { void setup() { _navKey = GlobalObjectKey(this); - WidgetsBinding.instance?.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { if (widget.route != null) { _navKey.currentState?.pushReplacementNamed( widget.route!.name!, diff --git a/deprecated/storyboard/lib/src/render_lane.dart b/deprecated/storyboard/lib/src/render_lane.dart index f12afb1..c2f7152 100644 --- a/deprecated/storyboard/lib/src/render_lane.dart +++ b/deprecated/storyboard/lib/src/render_lane.dart @@ -61,7 +61,6 @@ class _Lane extends StatelessWidget { required this.androidDevice, required this.cupertinoDevice, this.title, - this.itemBuilder, this.laneBuilder, this.size, this.shadow, diff --git a/deprecated/widget_gen/lib/src/class_annotation_gen.dart b/deprecated/widget_gen/lib/src/class_annotation_gen.dart index 1cf0cf2..11cf069 100644 --- a/deprecated/widget_gen/lib/src/class_annotation_gen.dart +++ b/deprecated/widget_gen/lib/src/class_annotation_gen.dart @@ -58,18 +58,16 @@ class WidgetGenerator extends Generator { if (isPropertyClass(baseClass)) { _base = 'PropertyBase'; } - if (_base != null) { - final _template = MixinStoreTemplate(_base) - ..width = width - ..height = height; - yield _generateCodeFromTemplate( - baseClass.name, - baseClass, - _template, - typeNameFinder, - ); + final _template = MixinStoreTemplate(_base) + ..width = width + ..height = height; + yield _generateCodeFromTemplate( + baseClass.name, + baseClass, + _template, + typeNameFinder, + ); } - } String _generateCodeFromTemplate( String publicTypeName, diff --git a/deprecated/widget_gen/lib/src/template/comma_list.dart b/deprecated/widget_gen/lib/src/template/comma_list.dart index c84008b..832947b 100644 --- a/deprecated/widget_gen/lib/src/template/comma_list.dart +++ b/deprecated/widget_gen/lib/src/template/comma_list.dart @@ -1,7 +1,7 @@ import 'util.dart'; class CommaList { - CommaList(this.templates) : assert(templates != null); + CommaList(this.templates); final List templates; @@ -11,10 +11,7 @@ class CommaList { } class SurroundedCommaList { - SurroundedCommaList(this.prefix, this.suffix, this.templates) - : assert(prefix != null), - assert(suffix != null), - assert(templates != null); + SurroundedCommaList(this.prefix, this.suffix, this.templates); final String prefix; final String suffix; diff --git a/deprecated/widget_gen/lib/src/template/params.dart b/deprecated/widget_gen/lib/src/template/params.dart index c5eb655..e12a6b9 100644 --- a/deprecated/widget_gen/lib/src/template/params.dart +++ b/deprecated/widget_gen/lib/src/template/params.dart @@ -11,9 +11,7 @@ class ParamTemplate { String get metadata => hasRequiredAnnotation ? '@required ' : ''; @override - String toString() => defaultValue == null - ? '$metadata$type $name' - : '$type $name = $defaultValue'; + String toString() => '$type $name = $defaultValue'; } class TypeParamTemplate { @@ -23,7 +21,7 @@ class TypeParamTemplate { String get asArgument => name; @override - String toString() => bound == null ? name : '$name extends $bound'; + String toString() => '$name extends $bound'; } class NamedArgTemplate { diff --git a/deprecated/widget_gen/lib/src/template/properties/base.dart b/deprecated/widget_gen/lib/src/template/properties/base.dart index 258580e..8210fb7 100644 --- a/deprecated/widget_gen/lib/src/template/properties/base.dart +++ b/deprecated/widget_gen/lib/src/template/properties/base.dart @@ -23,24 +23,18 @@ class BaseOptionTemplate extends SettingsImpl { sb.write('return '); if (tryParse) { sb.write("$propertyType.tryParse(params[${name}Key].toString())"); - if (defaultValue != null) { - sb.write(' ?? $defaultValue'); - } - } else { + sb.write(' ?? $defaultValue'); + } else { sb.write('params[${name}Key] as $propertyType'); } sb.writeln(';'); sb.writeln('}'); - if (defaultValue != null) { - if (propertyType == 'String') { - sb.writeln("return '$defaultValue';"); - } else { - sb.writeln("return $defaultValue;"); - } + if (propertyType == 'String') { + sb.writeln("return '$defaultValue';"); } else { - sb.writeln("return null;"); + sb.writeln("return $defaultValue;"); } - sb.writeln('}'); + sb.writeln('}'); sb.writeln('set ${name}Val($propertyType val) {'); sb.writeln('params[${name}Key] = val;'); sb.writeln('widgetContext.onUpdate(id, widgetData);'); diff --git a/deprecated/widget_gen/lib/src/template/properties/color.dart b/deprecated/widget_gen/lib/src/template/properties/color.dart index e6818eb..c657185 100644 --- a/deprecated/widget_gen/lib/src/template/properties/color.dart +++ b/deprecated/widget_gen/lib/src/template/properties/color.dart @@ -38,12 +38,8 @@ class ColorOptionTemplate extends SettingsImpl { sb.write('return $propertyType(_value);'); sb.writeln('}'); sb.writeln('}'); - if (defaultValue != null) { - sb.writeln("return $propertyType($defaultValue);"); - } else { - sb.writeln("return null;"); - } - sb.writeln('}'); + sb.writeln("return $propertyType($defaultValue);"); + sb.writeln('}'); // Setter sb.writeln('set ${name}Val($propertyType val) {'); sb.write('params[${name}Key] = "'); diff --git a/deprecated/widget_gen/lib/src/template/properties/enum.dart b/deprecated/widget_gen/lib/src/template/properties/enum.dart index b4909f1..1d7728d 100644 --- a/deprecated/widget_gen/lib/src/template/properties/enum.dart +++ b/deprecated/widget_gen/lib/src/template/properties/enum.dart @@ -29,7 +29,7 @@ class EnumOptionTemplate extends SettingsImpl { sb.write('final _value = '); sb.writeln("params[${name}Key].toString().replaceAll('#', '');"); final _fallback = - defaultValue == null ? null : _getEnumValueFromString(defaultValue); + _getEnumValueFromString(defaultValue); sb.writeln(""" return ${name}Values.firstWhere( (element) => element.toString() == _value, @@ -58,7 +58,6 @@ class EnumOptionTemplate extends SettingsImpl { } T getEnum(String val, {T fallback, List values}) { - if (val == null) return fallback; final _value = val.replaceAll('#', ''); return values.firstWhere( (element) => element.toString() == _value, diff --git a/deprecated/widget_gen/lib/src/template/properties/function.dart b/deprecated/widget_gen/lib/src/template/properties/function.dart index eb717f7..c3ce579 100644 --- a/deprecated/widget_gen/lib/src/template/properties/function.dart +++ b/deprecated/widget_gen/lib/src/template/properties/function.dart @@ -23,12 +23,8 @@ class FunctionOptionTemplate extends SettingsImpl { sb.write('params[${name}Key] as String'); sb.writeln(';'); sb.writeln('}'); - if (defaultValue != null) { - sb.writeln("return $defaultValue;"); - } else { - sb.writeln("return null;"); - } - sb.writeln('}'); + sb.writeln("return $defaultValue;"); + sb.writeln('}'); sb.writeln('set ${name}Val(String val) {'); sb.writeln('params[${name}Key] = val;'); sb.writeln('widgetContext.onUpdate(id, widgetData);'); @@ -40,13 +36,10 @@ class FunctionOptionTemplate extends SettingsImpl { String constructor() { final sb = StringBuffer(); sb.write(' '); - if (key != null && int.tryParse(key) != null) { + if (int.tryParse(key) != null) { sb.write(''); - } else if (key != null) { - sb.write("$key: "); - } else { - sb.write("$name: "); - } + } else sb.write("$key: "); + sb.writeln("() => onAction(context, ${name}Val)"); sb.writeln(','); return sb.toString(); diff --git a/deprecated/widget_gen/lib/src/template/properties/impl.dart b/deprecated/widget_gen/lib/src/template/properties/impl.dart index 65ab749..7e2dcde 100644 --- a/deprecated/widget_gen/lib/src/template/properties/impl.dart +++ b/deprecated/widget_gen/lib/src/template/properties/impl.dart @@ -11,13 +11,10 @@ abstract class SettingsImpl { String constructor() { final sb = StringBuffer(); sb.write(' '); - if (key != null && int.tryParse(key) != null) { + if (int.tryParse(key) != null) { sb.write('${name}Val'); - } else if (key != null) { - sb.write("$key: ${name}Val"); - } else { - sb.write("$name: ${name}Val"); - } + } else sb.write("$key: ${name}Val"); + sb.writeln(','); return sb.toString(); } diff --git a/deprecated/widget_gen/lib/src/template/properties/key.dart b/deprecated/widget_gen/lib/src/template/properties/key.dart index bb5a8a5..4a342d7 100644 --- a/deprecated/widget_gen/lib/src/template/properties/key.dart +++ b/deprecated/widget_gen/lib/src/template/properties/key.dart @@ -34,12 +34,8 @@ class KeyOptionTemplate extends SettingsImpl { """); sb.writeln(';'); sb.writeln('}'); - if (defaultValue != null) { - sb.writeln("return ValueKey('$defaultValue');"); - } else { - sb.writeln("return null;"); - } - sb.writeln('}'); + sb.writeln("return ValueKey('$defaultValue');"); + sb.writeln('}'); sb.writeln('set ${name}Val($propertyType val) {'); sb.write(""" if (val == null) { diff --git a/deprecated/widget_gen/lib/src/template/properties/list_widget.dart b/deprecated/widget_gen/lib/src/template/properties/list_widget.dart index 3a7ce58..27e67f9 100644 --- a/deprecated/widget_gen/lib/src/template/properties/list_widget.dart +++ b/deprecated/widget_gen/lib/src/template/properties/list_widget.dart @@ -33,21 +33,17 @@ class ListWidgetOptionTemplate extends SettingsImpl { return _children; """); sb.writeln('}'); - if (fallback != null) { - final random = DateTime.now().millisecondsSinceEpoch.toString(); - sb.writeln(""" - return [ - widgetRender({ - 'id': '$random', - 'name': '$fallback', - 'params': {}, - }) - ]; - """); - } else { - sb.writeln("return null;"); - } - sb.writeln('}'); + final random = DateTime.now().millisecondsSinceEpoch.toString(); + sb.writeln(""" + return [ + widgetRender({ + 'id': '$random', + 'name': '$fallback', + 'params': {}, + }) + ]; + """); + sb.writeln('}'); sb.writeln('void ${name}ValUpdate(Map val) {'); sb.write(""" if (params[${name}Key] == null) { @@ -64,19 +60,16 @@ class ListWidgetOptionTemplate extends SettingsImpl { String constructor() { final sb = StringBuffer(); sb.write(' '); - if (key != null && int.tryParse(key) != null) { + if (int.tryParse(key) != null) { sb.write(''); - } else if (key != null) { - sb.write("$key: "); - } else { - sb.write("$name: "); - } + } else sb.write("$key: "); + sb.write(""" ${name}Val == null && !widgetContext.isDragging ? ${empty ? '[]' : 'null'} : [ if (${name}Val != null) for (final item in ${name}Val) item.build(context), """); - if (acceptType != null && acceptType.isNotEmpty) { + if (acceptType.isNotEmpty) { sb.write(""" if (widgetContext.isDragging) DragTarget<$acceptType>( diff --git a/deprecated/widget_gen/lib/src/template/properties/supported.dart b/deprecated/widget_gen/lib/src/template/properties/supported.dart index 9b61178..76af12f 100644 --- a/deprecated/widget_gen/lib/src/template/properties/supported.dart +++ b/deprecated/widget_gen/lib/src/template/properties/supported.dart @@ -35,13 +35,10 @@ class SupportedOptionTemplate extends SettingsImpl { String constructor() { final sb = StringBuffer(); sb.write(' '); - if (key != null && int.tryParse(key) != null) { + if (int.tryParse(key) != null) { sb.write(''); - } else if (key != null) { - sb.write("$key: "); - } else { - sb.write("$name: "); - } + } else sb.write("$key: "); + sb.writeln("${name}Val?.build(context)"); sb.writeln(','); return sb.toString(); diff --git a/deprecated/widget_gen/lib/src/template/properties/widget.dart b/deprecated/widget_gen/lib/src/template/properties/widget.dart index 3662cc7..a0ba07e 100644 --- a/deprecated/widget_gen/lib/src/template/properties/widget.dart +++ b/deprecated/widget_gen/lib/src/template/properties/widget.dart @@ -21,10 +21,8 @@ class WidgetOptionTemplate extends SettingsImpl { @override String access() { final sb = StringBuffer(); - if (acceptType != null) { - sb.writeln('final _${name}Listen = ValueNotifier(false);'); - } - sb.writeln('WidgetBase get ${name}Val {'); + sb.writeln('final _${name}Listen = ValueNotifier(false);'); + sb.writeln('WidgetBase get ${name}Val {'); sb.write("if (params[${name}Key] != null) "); sb.writeln('{'); sb.write('return '); @@ -54,69 +52,60 @@ class WidgetOptionTemplate extends SettingsImpl { String constructor() { final sb = StringBuffer(); sb.write(' '); - if (key != null && int.tryParse(key) != null) { + if (int.tryParse(key) != null) { sb.write(''); - } else if (key != null) { - sb.write("$key: "); - } else { - sb.write("$name: "); - } - if (acceptType == null) { - sb.writeln('${name}Val?.build(context)'); - } else { + } else sb.write("$key: "); + + sb.write(""" + !widgetContext.isDragging || (widgetContext.isDragging && ${name}Val?.build(context) != null) ? + ( + ${name}Val?.build(context) + + """); + sb.write(""" + ?? (widgetRender(widgetContext, json.decode(json.encode({ + 'id': '${shortid.generate()}', + 'name': '$fallback', + 'params': {}, + })))).build(context) + """); sb.write(""" - !widgetContext.isDragging || (widgetContext.isDragging && ${name}Val?.build(context) != null) ? - ( - ${name}Val?.build(context) - - """); - if (fallback != null) { - sb.write(""" - ?? (widgetRender(widgetContext, json.decode(json.encode({ - 'id': '${shortid.generate()}', - 'name': '$fallback', - 'params': {}, - })))).build(context) - """); - } - sb.write(""" - ) - """); - sb.write(""" - : - PreferredSize( - preferredSize: Size(${acceptWidth ?? 30}, ${acceptHeight ?? 30}), - child: DragTarget<$acceptType>( - onAccept: (val) { - _${name}Listen.value = false; - if (val != null) { - ${name}ValUpdate(val?.data); - } - }, - onLeave: (val) { - _${name}Listen.value = false; - }, - onWillAccept: (val) { - _${name}Listen.value = true; - return _${name}Listen.value; - }, - builder: (context, accepted, rejected) { - return ValueListenableBuilder( - valueListenable: _${name}Listen, - builder: (context, _accepting, child) => SizedBox.fromSize( - size: Size(${acceptWidth ?? 30}, ${acceptHeight ?? 30}), - child: Placeholder( - color: !_accepting ? - Colors.grey : - Theme.of(context).accentColor, - ), - )); - }, - ), - ) - """); - } - sb.writeln(','); + ) + """); + sb.write(""" + : + PreferredSize( + preferredSize: Size(${acceptWidth ?? 30}, ${acceptHeight ?? 30}), + child: DragTarget<$acceptType>( + onAccept: (val) { + _${name}Listen.value = false; + if (val != null) { + ${name}ValUpdate(val?.data); + } + }, + onLeave: (val) { + _${name}Listen.value = false; + }, + onWillAccept: (val) { + _${name}Listen.value = true; + return _${name}Listen.value; + }, + builder: (context, accepted, rejected) { + return ValueListenableBuilder( + valueListenable: _${name}Listen, + builder: (context, _accepting, child) => SizedBox.fromSize( + size: Size(${acceptWidth ?? 30}, ${acceptHeight ?? 30}), + child: Placeholder( + color: !_accepting ? + Colors.grey : + Theme.of(context).accentColor, + ), + )); + }, + ), + ) + """); + sb.writeln(','); return sb.toString(); } } diff --git a/deprecated/widget_gen/lib/src/template/widget_class_gen.dart b/deprecated/widget_gen/lib/src/template/widget_class_gen.dart index d776f0a..36e556b 100644 --- a/deprecated/widget_gen/lib/src/template/widget_class_gen.dart +++ b/deprecated/widget_gen/lib/src/template/widget_class_gen.dart @@ -21,20 +21,15 @@ class MixinStoreTemplate extends StoreTemplate { if (_hasPreferredSize) { sb.writeln('@override'); sb.write('Size get preferredSize => '); - if (width != null && height != null) { - sb.write('Size($width, $height)'); - } else if (width != null) { - sb.write('Size.fromWidth($width)'); - } else if (height != null) { - sb.write('Size.fromHeight($height)'); - } + sb.write('Size($width, $height)'); + sb.writeln(';'); } sb.writeln(''); sb.writeln('@override'); sb.writeln('Map get properties => {'); for (final setting in settings) { - sb.write("'${setting?.key ?? setting.name}'"); + sb.write("'${setting.key ?? setting.name}'"); sb.write(':'); sb.write("'${setting.propertyType}'"); sb.writeln(','); @@ -62,7 +57,7 @@ class MixinStoreTemplate extends StoreTemplate { sb.write('Animated'); } sb.writeln('$widgetName('); - settings.sort((a, b) => (a?.key ?? a.name).compareTo((b?.key ?? b.name))); + settings.sort((a, b) => (a.key ?? a.name).compareTo((b.key ?? b.name))); if (isAnimated) { sb.writeln( 'duration: const Duration(milliseconds: $animatedDurationMilliseconds),'); diff --git a/deprecated/widget_gen/lib/src/type_names.dart b/deprecated/widget_gen/lib/src/type_names.dart index dc8a830..de13d69 100644 --- a/deprecated/widget_gen/lib/src/type_names.dart +++ b/deprecated/widget_gen/lib/src/type_names.dart @@ -24,10 +24,8 @@ class LibraryScopedNameFinder { Map _namesByElement; Map get namesByElement { - if (_namesByElement != null) { - return _namesByElement; - } - + return _namesByElement; + _namesByElement = {}; // Add all of this library's type-defining elements to the name map diff --git a/experimental/pocketbase_auth/lib/src/ui/login_screen.dart b/experimental/pocketbase_auth/lib/src/ui/login_screen.dart index 1c0550b..e36032b 100644 --- a/experimental/pocketbase_auth/lib/src/ui/login_screen.dart +++ b/experimental/pocketbase_auth/lib/src/ui/login_screen.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; import '../../pocketbase_auth.dart'; -import '../auth_service.dart'; -import '../view_models/login_view_model.dart'; class PocketBaseLoginScreen extends StatefulWidget { final AuthService authService; diff --git a/experimental/pocketbase_sync/example/lib/ui/home_page.dart b/experimental/pocketbase_sync/example/lib/ui/home_page.dart index dc7f6af..f0aad11 100644 --- a/experimental/pocketbase_sync/example/lib/ui/home_page.dart +++ b/experimental/pocketbase_sync/example/lib/ui/home_page.dart @@ -104,7 +104,7 @@ class _SyncHomePageState extends State { final auth = await pb .collection('users') .authWithPassword(email, password); - _currentUserEmail = auth.record?.getStringValue('email'); + _currentUserEmail = auth.record.getStringValue('email'); } catch (e, stack) { _logger.warning('Auth failed', e, stack); }