Port a few widgets to null safety

This commit is contained in:
Vishesh Handa
2021-05-17 16:37:26 +02:00
parent 74fd96fa50
commit 8d4de537e7
3 changed files with 21 additions and 27 deletions

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class HighlightedText extends StatelessWidget { class HighlightedText extends StatelessWidget {
@ -8,15 +6,15 @@ class HighlightedText extends StatelessWidget {
final String highlightTextLowerCase; final String highlightTextLowerCase;
final TextStyle style; final TextStyle style;
final TextStyle highlightStyle; final TextStyle? highlightStyle;
final TextOverflow overflow; final TextOverflow? overflow;
final int maxLines; final int? maxLines;
HighlightedText({ HighlightedText({
@required this.text, required this.text,
@required this.highlightText, required this.highlightText,
@required this.highlightTextLowerCase, required this.highlightTextLowerCase,
@required this.style, required this.style,
this.highlightStyle, this.highlightStyle,
this.overflow, this.overflow,
this.maxLines, this.maxLines,
@ -61,14 +59,14 @@ class HighlightTextSpan {
final String highlightTextLowerCase; final String highlightTextLowerCase;
final TextStyle style; final TextStyle style;
final TextStyle highlightStyle; TextStyle? highlightStyle;
HighlightTextSpan({ HighlightTextSpan({
@required this.text, required this.text,
@required this.highlightText, required this.highlightText,
@required this.highlightTextLowerCase, required this.highlightTextLowerCase,
@required this.style, required this.style,
this.highlightStyle, required this.highlightStyle,
}); });
List<InlineSpan> build(BuildContext context) { List<InlineSpan> build(BuildContext context) {

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -8,11 +6,11 @@ class IconDismissable extends Dismissible {
final IconData iconData; final IconData iconData;
IconDismissable({ IconDismissable({
@required Key key, required Key key,
@required this.backgroundColor, required this.backgroundColor,
@required this.iconData, required this.iconData,
@required Function onDismissed, required Function(DismissDirection) onDismissed,
@required Widget child, required Widget child,
}) : super( }) : super(
key: key, key: key,
child: child, child: child,

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@ -15,13 +13,13 @@ class MarkdownToolBar extends StatelessWidget {
final TextEditingController textController; final TextEditingController textController;
MarkdownToolBar({ MarkdownToolBar({
@required this.textController, required this.textController,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var textTheme = Theme.of(context).textTheme; var textTheme = Theme.of(context).textTheme;
var style = textTheme.bodyText2.copyWith(fontWeight: FontWeight.bold); var style = textTheme.bodyText2!.copyWith(fontWeight: FontWeight.bold);
return Container( return Container(
child: Row( child: Row(
@ -151,7 +149,7 @@ TextEditingValue modifyCurrentLine(
for (var blockTagRegExp in _allowedBlockRegExps) { for (var blockTagRegExp in _allowedBlockRegExps) {
var match = blockTagRegExp.matchAsPrefix(text, lineStartPos); var match = blockTagRegExp.matchAsPrefix(text, lineStartPos);
if (match != null) { if (match != null) {
var blockTag = match.group(0); var blockTag = match.group(0)!;
var newVal = _removeFromLine(text, cursorPos, lineStartPos, blockTag); var newVal = _removeFromLine(text, cursorPos, lineStartPos, blockTag);
if (blockTag == char) { if (blockTag == char) {
return newVal; return newVal;