Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Fix errors & warnings in radio_buttons examples #114

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions docs/components/dartpad/radio_buttons/regular/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';

void main() => runApp(MyApp());
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
return const MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
home: MyHomePage(),
Expand All @@ -14,13 +16,16 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});

@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _value = 1;
int? _value = 1;

@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
Expand All @@ -32,15 +37,15 @@ class _MyHomePageState extends State<MyHomePage> {
style: Theme.of(context)
.textTheme
.subtitle1
.copyWith(color: i == 5 ? Colors.black38 : Colors.black),
?.copyWith(color: i == 5 ? Colors.black38 : Colors.black),
),
leading: Radio(
value: i,
groupValue: _value,
activeColor: Color(0xFF6200EE),
activeColor: const Color(0xFF6200EE),
onChanged: i == 5
? null
: (int value) {
: (int? value) {
setState(() {
_value = value;
});
Expand Down
31 changes: 16 additions & 15 deletions docs/components/dartpad/radio_buttons/theme/main.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import 'package:flutter/material.dart';

void main() => runApp(MyApp());
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
home: MyHomePage(),
home: const MyHomePage(),
theme: _buildShrineTheme(),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});

@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _value = 1;
int? _value = 1;

@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
Expand All @@ -33,14 +38,14 @@ class _MyHomePageState extends State<MyHomePage> {
style: Theme.of(context)
.textTheme
.subtitle1
.copyWith(color: i == 5 ? Colors.black38 : shrineBrown900),
?.copyWith(color: i == 5 ? Colors.black38 : shrineBrown900),
),
leading: Radio(
value: i,
groupValue: _value,
onChanged: i == 5
? null
: (int value) {
: (int? value) {
setState(() {
_value = value;
});
Expand All @@ -56,14 +61,12 @@ class _MyHomePageState extends State<MyHomePage> {
ThemeData _buildShrineTheme() {
final ThemeData base = ThemeData.light();
return base.copyWith(
colorScheme: _shrineColorScheme,
toggleableActiveColor: shrinePink400,
accentColor: shrineBrown900,
primaryColor: shrinePink100,
buttonColor: shrinePink100,
scaffoldBackgroundColor: shrineBackgroundWhite,
cardColor: shrineBackgroundWhite,
textSelectionTheme: TextSelectionThemeData(selectionColor: shrinePink100),
textSelectionTheme:
const TextSelectionThemeData(selectionColor: shrinePink100),
errorColor: shrineErrorRed,
buttonTheme: const ButtonThemeData(
colorScheme: _shrineColorScheme,
Expand All @@ -72,8 +75,8 @@ ThemeData _buildShrineTheme() {
primaryIconTheme: _customIconTheme(base.iconTheme),
textTheme: _buildShrineTextTheme(base.textTheme),
primaryTextTheme: _buildShrineTextTheme(base.primaryTextTheme),
accentTextTheme: _buildShrineTextTheme(base.accentTextTheme),
iconTheme: _customIconTheme(base.iconTheme),
colorScheme: _shrineColorScheme.copyWith(secondary: shrineBrown900),
);
}

Expand All @@ -84,12 +87,12 @@ IconThemeData _customIconTheme(IconThemeData original) {
TextTheme _buildShrineTextTheme(TextTheme base) {
return base
.copyWith(
caption: base.caption.copyWith(
caption: base.caption?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: defaultLetterSpacing,
),
button: base.button.copyWith(
button: base.button?.copyWith(
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: defaultLetterSpacing,
Expand All @@ -104,9 +107,7 @@ TextTheme _buildShrineTextTheme(TextTheme base) {

const ColorScheme _shrineColorScheme = ColorScheme(
primary: shrinePink100,
primaryVariant: shrineBrown900,
secondary: shrinePink50,
secondaryVariant: shrineBrown900,
surface: shrineSurfaceWhite,
background: shrineBackgroundWhite,
error: shrineErrorRed,
Expand Down