This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2024 Fredrick Allan Hrott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_localizations/flutter_localizations.dart'; | |
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
// General idea is the localizations in the model are referred to as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AppLocalizations.of(appRouterContext).localizationKey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:better_localization_steps/src/app_globals.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | |
import 'package:flutter_localizations/flutter_localizations.dart'; | |
import 'sample_feature/sample_item_details_view.dart'; | |
import 'sample_feature/sample_item_list_view.dart'; | |
import 'settings/settings_controller.dart'; | |
import 'settings/settings_view.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2024 Fredrick Allan Hrott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
// So this is how we will get the context to use in any models as | |
// the scaffoldMessengerKey will be supplied to the MaterialApp | |
// and then the appRouterContext will be the context referred to | |
// in the AppLocalisations.of().localizationKey call in the model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_localizations/flutter_localizations.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:localization_wo_context/generated/l10n.dart'; | |
import 'package:localization_wo_context/generated/l10n.dart'; | |
import 'package:localization_wo_context/generated/l10n.dart'; | |
late final appNavKey; | |
void main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
final navigatorKey = GlobalKey<NavigatorState>(); | |
// navigatorKey is parameter which goes in the MaterialApp | |
// navigagtorKey parameter slot. Then we can do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Container extends Coding { | |
List<String> things; | |
@override | |
Map<String, cast.Cast<dynamic>> get castMap => { | |
"things": cast.List(cast.String) | |
}; | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Team extends Coding { | |
List<Person> members; | |
Person manager; | |
@override | |
void decode(KeyedArchive object) { | |
super.decode(object); // must call super | |
members = object.decodeObjects("members", () => Person()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// decode | |
final json = json.decode(...); | |
final archive = KeyedArchive.unarchive(json); | |
final person = Person()..decode(archive); | |
//encode | |
final person = Person()..name = "Bob"; | |
final archive = KeyedArchive.archive(person); | |
final json = json.encode(archive); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person extends Coding { | |
String name; | |
@override | |
void decode(KeyedArchive object) { | |
// must call super | |
super.decode(object); | |
name = object.decode("name"); | |
} |
NewerOlder