I can't seem to find documentation on Focusing on anything other than a TextField on initial load of a page.
I have a Terms and Condition page and I am trying to make the first item on the page (being the logo) to focus first. Instead, the first focus once you swipe right for the first time highlights the container the logo, paragraph text, and action buttons. Once this is in focus it reads the paragraph text instead of the logo first.
My goal is to prevent the focus on the container and to go straight to the logo. So no focus on container only the items within it. From there the focus would then go to the paragraph text then action buttons.
Here is my code:
landing_page.dart
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:spectrum_access_flutter/views/widgets/buttons/negative_button.dart';
import 'package:spectrum_access_flutter/views/widgets/buttons/primary_button.dart';
import 'package:spectrum_access_flutter/views/widgets/buttons/secondary_button.dart';
class LandingPage extends StatefulWidget {
static const path = 'Terms';
@override
_LandingPageState createState() => _LandingPageState();
}
class _LandingPageState extends State<LandingPage> {
// Define the focus node. To manage the lifecycle, create the FocusNode in
// the initState method, and clean it up in the dispose method.
FocusNode myFocusNode;
bool isVisible = false;
@override
void initState() {
super.initState();
myFocusNode = FocusNode();
}
@override
void dispose() {
// Clean up the focus node when the Form is disposed.
myFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: Center(
child: new ListView(
shrinkWrap: true,
padding: new EdgeInsets.all(25.0),
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(5.0),
child: Image.network(
''
'https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png',
semanticLabel: 'Flutter Logo',
width: 270.0,
focusNode: myFocusNode
),
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 30.0, 10, 30.0),
child: Align(
alignment: Alignment.center,
child: Container(
child: Text(
'To use Spectrum Access, please agree to the terms of service',
textAlign: TextAlign.center,
),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: SecondaryButton(
title: 'Terms and Conditions',
semanticLabel: 'Terms and Conditions',
onPressed: () {
print('Clicked Terms!');
}),
),
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: SecondaryButton(
title: 'Terms and Conditions',
semanticLabel: 'Privacy Policy',
onPressed: () {
print('Clicked Privacy!');
}),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 30.0, 0, 5.0),
child: PrimaryButton(
title: 'Agree',
onPressed: () async {
print('Clicked Agree!');
}),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 5.0),
child: NegativeButton(
title: 'Disagree',
onPressed: () {
print('Clicked Disagree!');
}),
),
],
)
]),
));
}
}
On line 53 focusNode: myFocusnode
Gives me this error: "The named parameter 'focusNode' isn't defined."
Followed these instructions --> https://flutter.dev/docs/cookbook/forms/focus