Files
GitJournal/lib/screens/onboarding_git_clone.dart
Vishesh Handa 3d88ed9c05 OnBoarding: Move cloning logic to parent widget
There were a few cases when since we were calling an async function in
initState, which would then call setState, we would get an exception.

Also this way, the entire logic of the onboarding is in one place, and
the individual screens are far far simpler.
2019-01-16 22:47:30 +01:00

59 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
class OnBoardingGitClone extends StatelessWidget {
final String errorMessage;
OnBoardingGitClone({
this.errorMessage,
});
@override
Widget build(BuildContext context) {
var children = <Widget>[];
if (this.errorMessage == null || this.errorMessage.isEmpty) {
children = <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Cloning ...',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.display1,
),
),
SizedBox(height: 8.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: CircularProgressIndicator(
value: null,
),
),
];
} else {
children = <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Failed',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.display1,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
this.errorMessage,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.display1,
),
),
];
}
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: children,
);
}
}